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