Exemplo n.º 1
0
        /// <summary>
        /// Edit View
        /// </summary>
        /// <param name="tagId">tagId</param>
        /// <returns>Edit View Model</returns>
        private PMS10001EditViewModel MakeEditViewModel(int tagId)
        {
            var model = new PMS10001EditViewModel();

            if (tagId > 0)
            {
                model.CUSTOMERTAG_INFO             = this._service.GetTagInfo(GetLoginUser().CompanyCode, tagId);
                model.CUSTOMERTAG_INFO.user_regist = model.CUSTOMERTAG_INFO.user_regist;
                model.CUSTOMERTAG_INFO.user_update = model.CUSTOMERTAG_INFO.user_update;
            }

            return(model);
        }
Exemplo n.º 2
0
        public ActionResult EditTag(PMS10001EditViewModel model)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    model.CUSTOMERTAG_INFO.upd_date     = Utility.GetCurrentDateTime();
                    model.CUSTOMERTAG_INFO.upd_id       = GetLoginUser().UserId;
                    model.CUSTOMERTAG_INFO.company_code = GetLoginUser().CompanyCode;

                    if (!model.CUSTOMERTAG_INFO.display_order.HasValue)
                    {
                        model.CUSTOMERTAG_INFO.display_order = 0;
                    }

                    int tagID = _service.EditTagData(model.CUSTOMERTAG_INFO);
                    if (tagID > 0)
                    {
                        string action  = Convert.ToInt32(model.CUSTOMERTAG_INFO.tag_id) > 0 ? "更新" : "登録";
                        string message = string.Format(Resources.Messages.I007, "タグ情報", action);
                        var    data    = this._service.GetTagInfo(GetLoginUser().CompanyCode, tagID);

                        JsonResult result = Json(
                            new
                        {
                            statusCode = 201,
                            message    = message,
                            id         = tagID,
                            insDate    = (data.ins_date != null) ? data.ins_date.ToString("yyyy/MM/dd HH:mm") : "",
                            updDate    = (data.upd_date != null) ? 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
                        },
                            JsonRequestBehavior.AllowGet);

                        return(result);
                    }
                    else
                    {
                        ModelState.AddModelError("", Resources.Messages.E001);
                        JsonResult result = Json(
                            new
                        {
                            statusCode = 500,
                            message    = string.Format(Resources.Messages.E045, "タグ情報")
                        },
                            JsonRequestBehavior.AllowGet);

                        return(result);
                    }
                }
                ModelState.AddModelError("", Resources.Messages.E001);
                return(new EmptyResult());
            }
            catch
            {
                JsonResult result = Json(
                    new
                {
                    statusCode = 500,
                    message    = string.Format(Resources.Messages.E045, "タグ情報")
                },
                    JsonRequestBehavior.AllowGet);

                return(result);
            }
        }