コード例 #1
0
ファイル: JobCategory.cs プロジェクト: eternalteach/BookWarm
        public ActionResult Edit(JobCategoryModel model)
        {
            if (ModelState.IsValid)
            {
                var jobCategory = jobCategoryService.GetById(model.Id);
                if (jobCategory == null)
                {
                    this.NotifyError("Item not found.");
                    return(RedirectToAction("List"));
                }
                else
                {
                    jobCategory.Name     = model.Name;
                    jobCategory.IsActive = model.IsActive;

                    var result = jobCategoryService.Update(jobCategory);
                    if (result)
                    {
                        this.NotifySuccess("Successfully saved.");
                    }
                    else
                    {
                        this.NotifyError("Item can not saved!");
                    }

                    urlService.Save(new UrlRecord()
                    {
                        EntityId   = jobCategory.Id,
                        EntityName = nameof(JobCategory),
                        Slug       = model.Name.ToUrlSlug()
                    });
                }

                return(RedirectToAction("Edit", new { id = model.Id }));
            }

            return(View(model));
        }