public async Task SaveAsync(MyDemoEntity demoentity) { using (var uow = _uowProvider.CreateUnitOfWork(false)) { var repository = uow.GetRepository <MyDemoEntity>(); if (demoentity.Id == 0) { repository.Add(demoentity); } else { repository.Update(demoentity); } await uow.SaveChangesAsync(); } }
public int Save(MyDemoEntity demoentity) { using (var uow = _uowProvider.CreateUnitOfWork(false)) { var repository = uow.GetRepository <MyDemoEntity>(); if (demoentity.Id == 0) { repository.Add(demoentity); } else { repository.Update(demoentity); } uow.SaveChanges(); return(demoentity.Id); } }
public async Task <IActionResult> UpdateAsync(int id, [FromBody] MyDemoEntity model) { await MyDemoEntityBusiness.SaveAsync(model); return(Ok()); }
public IActionResult Save([FromBody] MyDemoEntity myentity) { return(Ok(MyDemoEntityBusiness.Save(myentity))); //Return code is not ok, but you get the point... }