public async Task<Parenting> UpdateAsync(Parenting parenting) { using (var uow = _uowFac.Create()) { uow.ParentingRepository.Update(parenting); await uow.SaveChangesAsync(); return parenting; } }
public async Task<Parenting> InsertAsync(Parenting parenting) { using (var uow = _uowFac.Create()) { parenting.Id = new Guid(); uow.ParentingRepository.Insert(parenting); await uow.SaveChangesAsync(); return parenting; } }
public async Task<IHttpActionResult> PostParenting(Parenting parenting) { try { if (!ModelState.IsValid) return BadRequest(ModelState); var result = await _parentingService.InsertAsync(parenting); return Ok(result); } catch (Exception) { throw; } }
public async Task<IHttpActionResult> PutParenting(Parenting parenting) { try { if (!ModelState.IsValid) return BadRequest(ModelState); if (parenting.Id == Guid.Empty) return BadRequest(); var result = await _parentingService.UpdateAsync(parenting); return Ok(result); } catch (Exception) { throw; } }