示例#1
0
        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"));
        }
示例#2
0
        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));
        }
示例#3
0
        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());
            }
        }