Posts

c# - Adding to a table using MVC 5, and reset Id after deleting records -

i have 2 questions: first wrote code add doctors database, @ beginning code worked fine after adding validation doctor information not added table.. when press add button url goes to: /doctors/save why data not saved in database? , why after pressed add button program not redirect me add view? in controller there add() action add view contains adding form.. save() action html.beginform("save","doctors") inside add view.. here code: public actionresult add() { return view(); } [httppost] [validateantiforgerytoken] public actionresult save(doctor doctor) { if (!modelstate.isvalid) { var viewmodel = new doctorviewmodel { doctor = doctor }; return view("add", viewmodel); } if(doctor.id == 0) { _context.doctors.add(doctor); _context.savechanges(); return redirect("add"); } else ...

algorithm - List Occurence wise read c# -

i have class this public class roomdetails { public int roomindexid {get;set;} --(this no of rooms) public int roomcategoryid {get;set;} -- (this no of category room have) public decimal roomprice{get;set;} public string roomcategory{get;set;} } so have roomdetails list this(data) 1,1,200,single bed 2,1,250,double bed 2,2,400,double bed view 2,4,530,tripple bed 3,1,530,tripple bed 3,2,600,triple large bed so want read list following procedure. 1,1,200,single bed 2,1,250,double bed 3,1,530,tripple bed 1,1,200,single bed 2,1,250,double bed 3,2,600,triple large bed 1,1,200,single bed 2,2,400,double bed view 3,1,530,tripple bed 1,1,200,single bed 2,2,400,double bed view 3,2,600,triple large bed 1,1,200,single bed 2,4,530,tripple bed 3,1,530,tripple bed 1,1,200,single bed 2,4,530,tripple bed 3,2,600,triple large bed please ask if have problem regrading question. this example my data list this ...

In Spring data rest how to allow user to set value but ignore it in get request -

Image
in scenario i'm exposing following entity in spring data rest: public class user implements serializable { private static final long serialversionuid = 1l; @id @generatedvalue(strategy = generationtype.auto) @column(name = "user_id") private long userid; @notnull @size(min = 1, max = 50) @column(length = 50, unique = true, nullable = false) private string username; @jsonignore @notnull @size(min = 60, max = 60) @column(name = "password",length = 60) private string password; .... i password not exposed in response when performing on ../users/1 allowing hal browser know when performing post request needs set password. when i'm using @jsonignore hal browser not know needs set password field: how can it? possible? have tried adding @jsonignore in getter method instead of private string password property? ... @notnull @size(min = 60, max = 60) @column(name = "password",length = 60) private string password; ... @jsonigno...

ios - What is the use of Error, throws and catch? -

i'm trying head around use of errors in swift example have code: import uikit class viewcontroller: uiviewcontroller { enum someerror: error { case badword } override func viewdidload() { super.viewdidload() // additional setup after loading view, typically nib. { try checkword() } catch someerror.badword { print("error!") } catch { //this defualt statement print("something weird happened") } } func checkword() throws { let word = "crap" guard word != "crap" else { throw someerror.badword } print("continuing function") } override func didreceivememorywarning() { super.didreceivememorywarning() // dispose of resources can recreated. } } the checkword function terminate if word bad. same behaviour can achieved with: ...

java - Coordinate multiple threads after N executions -

i have java/groovy multi threaded process want "synchronize" after n executions: - shared counter decremented after each thread execution - goal reset counter once reaches 0 while no other thread accessing it. i tried readwritereentrantlock looks have race condition decrement phase. here test code public static void main(string[] args) { atomicinteger counter = new atomicinteger(decrementer.max_size) readwritelock lock = new reentrantreadwritelock() (int = 1; <= 10; i++) { decrementer d = new decrementer(counter, lock) new thread(d).start() } } public class decrementer implements runnable { public final static int max_size = 5 private readwritelock lock private atomicinteger counter public decrementer(atomicinteger counter, readwritelock lock) { this.counter = counter this.lock = lock } public void run() { while (true) { try{ lock.readlock().lock() ...

UWP (C#): Adding 3D object to app (Library Suggestion) -

i add 3d representation of imu app, i'm new uwp/app development , i'm not sure fastest/easiest way implement in image below. which 3d libraries recommend in order kind of output? 3d representation of imu i add 3d representation of imu app, i'm new uwp/app development , i'm not sure fastest/easiest way implement in image below. as far know, there no available library now. if want add 3d representation of imu app, can leverage direct3d api (it requires c++ coding). , there helper class library use: directxtk . also,if beginning build app. unity choice you. details using unity in uwp, please refer this case .

javascript - Resolve promises one after another (i.e. in sequence)? -

consider following code reads array of files in serial/sequential manner. readfiles returns promise, resolved once files have been read in sequence. var q = require("q"); var readfile = function(file) { ... // returns promise. }; var readfiles = function(files) { var deferred = q.defer(); var readsequential = function(index) { if (index >= files.length) { deferred.resolve(); } else { readfile(files[index]).then(function() { readsequential(index + 1); }); } }; readsequential(0); // start! return deferred.promise; }; the code above code works, don't having recursion things occur sequentially. there simpler way code can re-written don't have use weird readsequential function? originally tried use q.all , caused of readfile calls happen concurrently, not want: var readfiles = function(files) { return q.all(files.map(function(file) { return readfile(file); })); }; update 2017 : use a...