/// <summary> /// Make Edit view model /// </summary> /// <param name="categoryId"></param> /// <returns></returns> private PMS10004EditViewModel MakeEditViewModel(string company_code, int categoryId) { var model = new PMS10004EditViewModel(); if (categoryId > 0) { model.CATEGORY = this._service.GetCategoryInfo(company_code, categoryId); model.LIST_SUBCATEGORY = this._service.GetListSubCategory(company_code, categoryId); } return(model); }
public ActionResult EditCategory(PMS10004EditViewModel model) { try { if (ModelState.IsValid) { var loginUser = GetLoginUser(); model.CATEGORY.upd_date = Utility.GetCurrentDateTime(); model.CATEGORY.upd_id = loginUser.UserId; model.CATEGORY.company_code = loginUser.CompanyCode; int categoryID = _service.EditCategoryData(model.CATEGORY, model.LIST_SUBCATEGORY); if (categoryID > 0) { string action = model.CATEGORY.category_id > 0 ? "更新" : "登録"; string message = String.Format(Resources.Messages.I007, "カテゴリ情報", action); var data = this._service.GetCategoryInfo(loginUser.CompanyCode, categoryID); var subCategoryList = this._service.GetListSubCategory(loginUser.CompanyCode, categoryID); foreach (var subCate in subCategoryList) { subCate.sub_category = HttpUtility.HtmlEncode(subCate.sub_category); subCate.remarks = HttpUtility.HtmlEncode(subCate.remarks); subCate.sub_category_old = subCate.sub_category; subCate.remarks_old = subCate.remarks; } JsonResult result = Json( new { statusCode = 201, message = message, categoryID = categoryID, insDate = data.ins_date.ToString("yyyy/MM/dd HH:mm"), updDate = data.upd_date.ToString("yyyy/MM/dd HH:mm"), insUser = data.user_regist, updUser = data.user_update, deleted = data.del_flg.Equals(Constant.DeleteFlag.DELETE) ? true : false, subCategoryList = subCategoryList }, JsonRequestBehavior.AllowGet); return(result); } else { JsonResult result = Json( new { statusCode = 500, message = string.Format(Resources.Messages.E045, "カテゴリ情報") }, JsonRequestBehavior.AllowGet); return(result); } } return(new EmptyResult()); } catch { JsonResult result = Json( new { statusCode = 500, message = string.Format(Resources.Messages.E045, "カテゴリ情報") }, JsonRequestBehavior.AllowGet); return(result); } }