// PUT api/Default1/5 public async Task<IHttpActionResult> PutUserModel(int id, UserModel usermodel) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != usermodel.Id) { return BadRequest(); } db.Entry(usermodel).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!UserModelExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public async Task<IHttpActionResult> Register(UserModel userModel) { if (!ModelState.IsValid) { return BadRequest(ModelState); } UserModel result = await repository.RegisterUserAsync(userModel); return Ok(); }
public async Task<IHttpActionResult> PostUserModel(UserModel usermodel) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.Users.Add(usermodel); await db.SaveChangesAsync(); return CreatedAtRoute("DefaultApi", new { id = usermodel.Id }, usermodel); }
public async Task<UserModel> RegisterUserAsync(UserModel userModel) { ctx.Users.Add(userModel); await ctx.SaveChangesAsync(); return userModel; }
public async Task<UserModel> FindUser(string userName, string password) { UserModel userModel=new UserModel{Password=password,UserName=userName,ConfirmPassword=password}; var user = ctx.Users.Where(a => a.UserName == userName && a.Password == password).FirstOrDefault(); return user; }