public IHttpActionResult Post(Module module) { using (ModuleRepository _repo = new ModuleRepository(UnitOfWork)) { using (ModuleNameRepository _moduleNameRepo = new ModuleNameRepository(UnitOfWork)) { if (module.Id != default(int)) { // Need to specify the state of everything in order not to have double-ups module.State = State.Modified; module.Name.ForEach(n => _moduleNameRepo.InsertOrUpdate(n)); } _repo.InsertOrUpdate(module); UnitOfWork.Save(); } } return(Ok()); }
public IHttpActionResult Post(Module module) { using(ModuleRepository _repo = new ModuleRepository(UnitOfWork)) { using (ModuleNameRepository _moduleNameRepo = new ModuleNameRepository(UnitOfWork)) { if (module.Id != default(int)) { // Need to specify the state of everything in order not to have double-ups module.State = State.Modified; module.Name.ForEach(n => _moduleNameRepo.InsertOrUpdate(n)); } _repo.InsertOrUpdate(module); UnitOfWork.Save(); } } return Ok(); }