public async Task <ActionResult> UpdateSection(UpdateSectionModel model) { if (ModelState.IsValid) { var result = await sectionService.UpdateSection(model); if (result) { return(Ok()); } return(NotFound()); } return(BadRequest(ModelState)); }
public async Task <bool> UpdateSection(UpdateSectionModel model) { var sectionName = await context .SectionsNames .FirstOrDefaultAsync(sn => sn.SectionName == model.OldName); if (sectionName == null) { return(false); } sectionName.SectionName = model.SectionName; context.SectionsNames.Update(sectionName); await context.SaveChangesAsync(); return(true); }