public async Task <ActionResult> _Edit(EditSectorModel model) { var nameResponse = await WepApiMethod.SendApiAsync <bool>(HttpVerbs.Get, $"Administration/Sector/IsNameExist?id={model.Id}&name={model.Name}"); if (nameResponse.isSuccess) { TempData["ErrorMessage"] = Language.Sector.ValidExistName; return(RedirectToAction("List")); } if (ModelState.IsValid) { var response = await WepApiMethod.SendApiAsync <bool>(HttpVerbs.Put, $"Administration/Sector?id={model.Id}", model); if (response.isSuccess) { TempData["SuccessMessage"] = Language.Sector.AlertSuccessUpdate; LogActivity(Modules.Setting, "Update Parameter Sector", model); return(RedirectToAction("List")); } } TempData["ErrorMessage"] = Language.Sector.AlertFailUpdate; return(RedirectToAction("List")); }
public ActionResult _Edit(int id, string No, string Name) { var model = new EditSectorModel { Id = id, No = No, Name = Name }; return(View(model)); }
public IHttpActionResult Put(int id, [FromBody] EditSectorModel model) { var sector = db.Sector.Where(s => s.Id == id).FirstOrDefault(); if (sector != null) { sector.Name = model.Name; db.Entry(sector).State = EntityState.Modified; db.Entry(sector).Property(x => x.Display).IsModified = false; db.SaveChanges(); return(Ok(true)); } else { return(NotFound()); } }