public async Task <IActionResult> Edit([FromRoute] Guid Id, [FromBody] HospitalModel obj) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var data = _mapper.Map <Hospital>(obj); if (Id != data.Id) { return(BadRequest()); } _context.Entry(data).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!Exists(Id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutRooms([FromRoute] Guid Id, [FromBody] Room obj) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (Id != obj.Id) { return(BadRequest()); } _context.Entry(obj).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!Exists(Id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public User Authenticate(string username, string password) { if (string.IsNullOrEmpty(username) || string.IsNullOrEmpty(password)) { return(null); } var user = _context.Users.SingleOrDefault(x => x.Username == username); // check if username exists if (user == null) { return(null); } // check if password is correct if (!VerifyPasswordHash(password, user.PasswordHash, user.PasswordSalt)) { return(null); } // authentication successful _context.Entry(user).Reference("Role").Load(); return(user); }
public async Task <IActionResult> PutObject([FromRoute] Guid Id, [FromBody] AppointementStatusModel obj) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (Id != obj.Id) { return(BadRequest()); } var dataModel = _mapper.Map <AppointementStatus>(obj); _context.Entry(dataModel).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!Exists(Id)) { return(NotFound()); } else { throw; } } return(NoContent()); }