public async Task<Pediatrician> UpdateAsync(Pediatrician pediatrician) { using (var uow = _uowFac.Create()) { uow.PediatricianRepository.Update(pediatrician); await uow.SaveChangesAsync(); return pediatrician; } }
public async Task DeleteAsync(Pediatrician pediatrician) { using (var uow = _uowFac.Create()) { pediatrician.Deleted = true; uow.PediatricianRepository.Update(pediatrician); await uow.SaveChangesAsync(); } }
public async Task<Pediatrician> InsertAsync(Pediatrician pediatrician) { using (var uow = _uowFac.Create()) { pediatrician.Id = Guid.NewGuid(); uow.PediatricianRepository.Insert(pediatrician); await uow.SaveChangesAsync(); return pediatrician; } }
public async Task<IHttpActionResult> PostPediatrician(Pediatrician pediatrician) { try { if (!ModelState.IsValid) return BadRequest(ModelState); var result = await _pediatricianService.InsertAsync(pediatrician); return Ok(result); } catch (Exception) { throw; } }
public async Task<IHttpActionResult> PutPediatrician(Pediatrician pediatrician) { try { if (!ModelState.IsValid) return BadRequest(ModelState); if (pediatrician.Id == Guid.Empty) return BadRequest(); var result = await _pediatricianService.UpdateAsync(pediatrician); return Ok(result); } catch (Exception) { throw; } }