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