Example #1
0
        public ActionResult EditUser(PMS01002EditViewModel model)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    var tmp_user_sys_id = model.USER_INFO.user_sys_id;

                    //Check min lengthe of password
                    if (model.USER_INFO.password != Constant.DISPLAY_PASSWORD)
                    {
                        if (model.USER_INFO.password.Length < 6)
                        {
                            model = MakeEditViewModel(model.USER_INFO.user_sys_id);
                            ModelState.AddModelError("", string.Format(Resources.Messages.E023, "パスワード"));
                            return(new EmptyResult());
                        }

                        if (!Regex.IsMatch(model.USER_INFO.password, Constant.REG_PASSWORD))
                        {
                            model = MakeEditViewModel(model.USER_INFO.user_sys_id);
                            ModelState.AddModelError("", string.Format(Resources.Messages.E003, "パスワード"));
                            return(new EmptyResult());
                        }
                    }

                    HttpPostedFileBase file     = Request.Files["file"];
                    HttpPostedFileBase fileDrag = Request.Files["fileDrag"];

                    if (model.TypeUpload == "file" && file != null && file.FileName.Length > 0)
                    {
                        if (!Constant.AllowedFileExtensions.Contains(file.FileName.Substring(file.FileName.LastIndexOf('.'))))
                        {
                            model = MakeEditViewModel(model.USER_INFO.user_sys_id);
                            ModelState.AddModelError("", String.Format(Resources.Messages.E010, "jpg,png.jpeg"));
                            return(new EmptyResult());
                        }

                        if (file.ContentLength > Constant.MaxContentLength)
                        {
                            model = MakeEditViewModel(model.USER_INFO.user_sys_id);
                            ModelState.AddModelError("", String.Format(Resources.Messages.E021, "500KB以内"));
                            return(new EmptyResult());
                        }

                        model.USER_INFO.image_file_path = UploadFile.UploadFiles(ConfigurationManager.AppSettings[ConfigurationKeys.SAVE_BASE_FILE_PATH], file, ConfigurationManager.AppSettings[ConfigurationKeys.TEMP_USER_PATH]);
                    }
                    else if (model.TypeUpload == "fileDrag" && fileDrag != null && fileDrag.FileName.Length > 0)
                    {
                        file = fileDrag;

                        if (!Constant.AllowedFileExtensions.Contains(file.FileName.Substring(file.FileName.LastIndexOf('.'))))
                        {
                            model = MakeEditViewModel(model.USER_INFO.user_sys_id);
                            ModelState.AddModelError("", String.Format(Resources.Messages.E010, "jpg,png.jpeg"));
                            return(new EmptyResult());
                        }

                        if (file.ContentLength > Constant.MaxContentLength)
                        {
                            model = MakeEditViewModel(model.USER_INFO.user_sys_id);
                            ModelState.AddModelError("", String.Format(Resources.Messages.E021, "500KB以内"));
                            return(new EmptyResult());
                        }

                        model.USER_INFO.image_file_path = UploadFile.UploadFiles(ConfigurationManager.AppSettings[ConfigurationKeys.SAVE_BASE_FILE_PATH], file, ConfigurationManager.AppSettings[ConfigurationKeys.TEMP_USER_PATH]);
                    }
                    else
                    {
                        if (model.Clear == "1")
                        {
                            model.USER_INFO.image_file_path = string.Empty;
                        }
                    }

                    var loginUser = this.GetLoginUser();

                    model.USER_INFO.upd_date     = Utility.GetCurrentDateTime();
                    model.USER_INFO.upd_id       = loginUser.UserId;
                    model.USER_INFO.company_code = loginUser.CompanyCode;

                    if (model.USER_INFO.password != Constant.DISPLAY_PASSWORD)
                    {
                        model.USER_INFO.password = SafePassword.GetSaltedPassword(model.USER_INFO.password);
                        var user = _service.CheckPassword(model.USER_INFO.user_account, loginUser.CompanyCode, model.USER_INFO.user_sys_id);
                        if (user != null && model.USER_INFO.password == user.password)
                        {
                            model = MakeEditViewModel(model.USER_INFO.user_sys_id);
                            ModelState.AddModelError("", string.Format(Resources.Messages.E053));
                            return(new EmptyResult());
                        }
                    }

                    if (!string.IsNullOrEmpty(model.USER_INFO.mail_address_1) || !string.IsNullOrEmpty(model.USER_INFO.mail_address_2))
                    {
                        if (model.USER_INFO.mail_address_1.Trim() == model.USER_INFO.mail_address_2.Trim())
                        {
                            model = MakeEditViewModel(model.USER_INFO.user_sys_id);
                            ModelState.AddModelError("", String.Format(Resources.Messages.E008, "メールアドレス", "メールアドレス"));
                            return(new EmptyResult());
                        }

                        if (_service.CheckUserEmail(model.USER_INFO.mail_address_1, model.USER_INFO.mail_address_2, model.USER_INFO.user_sys_id, loginUser.CompanyCode) > 0)
                        {
                            model = MakeEditViewModel(model.USER_INFO.user_sys_id);
                            ModelState.AddModelError("", String.Format(Resources.Messages.E008, "メールアドレス", "メールアドレス"));
                            return(new EmptyResult());
                        }
                    }

                    if (_service.CheckUserAccount(model.USER_INFO.user_account, loginUser.CompanyCode, model.USER_INFO.user_sys_id) > 0)
                    {
                        model = MakeEditViewModel(model.USER_INFO.user_sys_id);
                        ModelState.AddModelError("", String.Format(Resources.Messages.E008, "ユーザーアカウント", "ユーザーアカウント"));
                        return(new EmptyResult());
                    }

                    if ((model.USER_INFO.user_sys_id == 0 ||
                         (model.OLD_DEL_FLAG &&
                          Constant.DeleteFlag.NON_DELETE.Equals(model.USER_INFO.del_flg))) &&
                        !this.commonService.CheckValidUpdateData(loginUser.CompanyCode, Constant.LicenseDataType.USER))
                    {
                        JsonResult result = Json(
                            new
                        {
                            statusCode = 500,
                            message    = string.Format(Resources.Messages.E067, "ユーザー")
                        },
                            JsonRequestBehavior.AllowGet);

                        return(result);
                    }

                    int userId = _service.EditUserData(model.USER_INFO);
                    if (userId > 0)
                    {
                        if (file != null && file.FileName.Length > 0)
                        {
                            UploadFile.CreateFolder(ConfigurationManager.AppSettings[ConfigurationKeys.SAVE_BASE_FILE_PATH] + ConfigurationManager.AppSettings[ConfigurationKeys.USER_PATH] + "/" + loginUser.CompanyCode + "/" + userId.ToString());
                            model.USER_INFO.user_sys_id = userId;
                            if (model.USER_INFO.del_flg == null)
                            {
                                model.USER_INFO.del_flg = Constant.DeleteFlag.NON_DELETE;
                            }
                            model.USER_INFO.image_file_path = ConfigurationManager.AppSettings[ConfigurationKeys.USER_PATH] + "/" + loginUser.CompanyCode + "/" + userId + "/" + ConfigurationManager.AppSettings[ConfigurationKeys.PROFILE_IMAGE] + file.FileName.Substring(file.FileName.LastIndexOf('.'));
                            model.USER_INFO.row_version     = this._service.GetUserInfo(loginUser.CompanyCode, userId).row_version;
                            if (_service.EditUserData(model.USER_INFO) > 0)
                            {
                                // Move image
                                UploadFile.MoveFile(ConfigurationManager.AppSettings[ConfigurationKeys.SAVE_BASE_FILE_PATH] + ConfigurationManager.AppSettings[ConfigurationKeys.TEMP_USER_PATH] + "/" +
                                                    file.FileName, ConfigurationManager.AppSettings[ConfigurationKeys.SAVE_BASE_FILE_PATH] + ConfigurationManager.AppSettings[ConfigurationKeys.USER_PATH] + "/" + loginUser.CompanyCode + "/" + userId + "/" + ConfigurationManager.AppSettings[ConfigurationKeys.PROFILE_IMAGE] + file.FileName.Substring(file.FileName.LastIndexOf('.')));
                            }
                        }

                        model.USER_INFO.user_sys_id = userId; //update new user_id to model

                        //update unit price history
                        if (_service.UpdateUnitPriceHistory(model.USER_INFO, model.USER_INFO.upd_id) > 0)
                        {
                            var sessionLogin = Session[Constant.SESSION_LOGIN_USER] as LoginUser;
                            if (sessionLogin.UserId == userId && sessionLogin.DisplayName != model.USER_INFO.display_name)
                            {
                                sessionLogin.DisplayName = model.USER_INFO.display_name;
                            }

                            if (sessionLogin.UserId == userId && sessionLogin.ImageFilePath != model.USER_INFO.image_file_path)
                            {
                                sessionLogin.ImageFilePath = model.USER_INFO.image_file_path;
                            }

                            if (sessionLogin.UserId == userId &&
                                sessionLogin.Password != model.USER_INFO.password &&
                                model.USER_INFO.password != Constant.DISPLAY_PASSWORD)
                            {
                                sessionLogin.Password            = model.USER_INFO.password;
                                sessionLogin.Is_expired_password = false;
                            }

                            if (sessionLogin.UserId == userId && sessionLogin.ActualWorkInputMode != model.USER_INFO.actual_work_input_mode)
                            {
                                sessionLogin.ActualWorkInputMode = model.USER_INFO.actual_work_input_mode;
                            }
                            SetLoginUser(sessionLogin);

                            string action  = Convert.ToInt32(tmp_user_sys_id) > 0 ? "更新" : "登録";
                            string message = string.Format(Resources.Messages.I007, "ユーザー情報", action);

                            var data = this._service.GetUserInfo(loginUser.CompanyCode, userId);

                            JsonResult result = Json(
                                new
                            {
                                statusCode       = 201,
                                message          = message,
                                id               = userId,
                                row_version      = Convert.ToBase64String(data.row_version),
                                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,
                                imageFilePath    = data.image_file_path,
                                userIDSesssion   = loginUser.UserId,
                                userNameSesssion = sessionLogin.DisplayName
                            },
                                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);
                        }
                    }
                    else
                    {
                        ModelState.AddModelError("", Resources.Messages.E001);

                        JsonResult result = Json(
                            new
                        {
                            statusCode = 500,
                            message    = string.Format(Resources.Messages.E045, "ユーザー情報")
                        },
                            JsonRequestBehavior.AllowGet);

                        return(result);
                    }
                }

                return(new EmptyResult());
            }
            catch (Exception)
            {
                JsonResult result = Json(
                    new
                {
                    statusCode = 500,
                    message    = string.Format(Resources.Messages.E045, "ユーザー情報")
                },
                    JsonRequestBehavior.AllowGet);

                return(result);
            }
        }
Example #2
0
        public ActionResult PersonalSetting(PMS01002PersonalSettingViewModel model)
        {
            try
            {
                int userId = GetLoginUser().UserId;
                if (userId > 0)
                {
                    model.USER_INFO.user_sys_id = userId;
                }

                if (ModelState.IsValid)
                {
                    if (model.USER_INFO.password != Constant.DISPLAY_PASSWORD)
                    {
                        if (model.USER_INFO.password.Length < 6)
                        {
                            model = MakePersonalSettingViewModel(userId);
                            ModelState.AddModelError("", string.Format(Resources.Messages.E023, "パスワード"));
                            return(new EmptyResult());
                        }

                        if (!Regex.IsMatch(model.USER_INFO.password, Constant.REG_PASSWORD))
                        {
                            model = MakePersonalSettingViewModel(userId);
                            ModelState.AddModelError("", string.Format(Resources.Messages.E003, "パスワード"));
                            return(new EmptyResult());
                        }
                    }

                    if (model.confirmPassword != Constant.DISPLAY_PASSWORD)
                    {
                        if (model.confirmPassword.Length < 6)
                        {
                            model = MakePersonalSettingViewModel(userId);
                            ModelState.AddModelError("", string.Format(Resources.Messages.E023, "パスワード(確認用)"));
                            return(new EmptyResult());
                        }

                        if (!Regex.IsMatch(model.confirmPassword, Constant.REG_PASSWORD))
                        {
                            model = MakePersonalSettingViewModel(userId);
                            ModelState.AddModelError("", string.Format(Resources.Messages.E003, "パスワード(確認用)"));
                            return(new EmptyResult());
                        }
                    }

                    if (model.USER_INFO.password != model.confirmPassword)
                    {
                        model = MakePersonalSettingViewModel(userId);
                        ModelState.AddModelError("", string.Format(Resources.Messages.E048));
                        return(new EmptyResult());
                    }

                    var sessionLogin = Session[Constant.SESSION_LOGIN_USER] as LoginUser;
                    if (model.USER_INFO.password != Constant.DISPLAY_PASSWORD)
                    {
                        if (SafePassword.GetSaltedPassword(model.USER_INFO.password) == sessionLogin.Password)
                        {
                            model = MakePersonalSettingViewModel(userId);
                            ModelState.AddModelError("", string.Format(Resources.Messages.E053));
                            return(new EmptyResult());
                        }
                    }

                    HttpPostedFileBase file     = Request.Files["file"];
                    HttpPostedFileBase fileDrag = Request.Files["fileDrag"];

                    if (model.TypeUpload == "file" && file != null && file.FileName.Length > 0)
                    {
                        if (!Constant.AllowedFileExtensions.Contains(file.FileName.Substring(file.FileName.LastIndexOf('.'))))
                        {
                            model = MakePersonalSettingViewModel(userId);
                            ModelState.AddModelError("", String.Format(Resources.Messages.E010, "jpg,png.jpeg"));
                            return(new EmptyResult());
                        }

                        if (file.ContentLength > Constant.MaxContentLength)
                        {
                            model = MakePersonalSettingViewModel(userId);
                            ModelState.AddModelError("", String.Format(Resources.Messages.E021, "500KB以内"));
                            return(new EmptyResult());
                        }

                        model.USER_INFO.image_file_path = UploadFile.UploadFiles(ConfigurationManager.AppSettings[ConfigurationKeys.SAVE_BASE_FILE_PATH], file, ConfigurationManager.AppSettings[ConfigurationKeys.TEMP_USER_PATH]);
                    }
                    else if (model.TypeUpload == "fileDrag" && fileDrag != null && fileDrag.FileName.Length > 0)
                    {
                        file = fileDrag;
                        if (!Constant.AllowedFileExtensions.Contains(file.FileName.Substring(file.FileName.LastIndexOf('.'))))
                        {
                            model = MakePersonalSettingViewModel(userId);
                            ModelState.AddModelError("", String.Format(Resources.Messages.E010, "jpg,png.jpeg"));
                            return(new EmptyResult());
                        }

                        if (file.ContentLength > Constant.MaxContentLength)
                        {
                            model = MakePersonalSettingViewModel(userId);
                            ModelState.AddModelError("", String.Format(Resources.Messages.E021, "500KB以内"));
                            return(new EmptyResult());
                        }

                        model.USER_INFO.image_file_path = UploadFile.UploadFiles(ConfigurationManager.AppSettings[ConfigurationKeys.SAVE_BASE_FILE_PATH], file, ConfigurationManager.AppSettings[ConfigurationKeys.TEMP_USER_PATH]);
                    }
                    else
                    {
                        if (model.Clear == "1")
                        {
                            model.USER_INFO.image_file_path = string.Empty;
                        }
                    }

                    model.USER_INFO.upd_date          = Utility.GetCurrentDateTime();
                    model.USER_INFO.upd_id            = userId;
                    model.USER_INFO.company_code      = GetLoginUser().CompanyCode;
                    model.USER_INFO.password_lock_flg = Constant.PasswordLockFlag.NON_LOCK;
                    model.USER_INFO.language_id       = (model.USER_INFO.language_id != null) ? model.USER_INFO.language_id : 0;

                    if (model.USER_INFO.password != Constant.DISPLAY_PASSWORD)
                    {
                        model.USER_INFO.password = SafePassword.GetSaltedPassword(model.USER_INFO.password);
                    }

                    if (!string.IsNullOrEmpty(model.USER_INFO.mail_address_1) || !string.IsNullOrEmpty(model.USER_INFO.mail_address_2))
                    {
                        if (model.USER_INFO.mail_address_1.Trim() == model.USER_INFO.mail_address_2.Trim())
                        {
                            model = MakePersonalSettingViewModel(userId);
                            ModelState.AddModelError("", String.Format(Resources.Messages.E008, "メールアドレス", "メールアドレス"));
                            return(new EmptyResult());
                        }

                        if (_service.CheckUserEmail(model.USER_INFO.mail_address_1, model.USER_INFO.mail_address_2, model.USER_INFO.user_sys_id, GetLoginUser().CompanyCode) > 0)
                        {
                            model = MakePersonalSettingViewModel(userId);
                            ModelState.AddModelError("", String.Format(Resources.Messages.E008, "メールアドレス", "メールアドレス"));
                            return(new EmptyResult());
                        }
                    }

                    if (_service.PersonalSettingUserData(model.USER_INFO) > 0)
                    {
                        if (file != null && file.FileName.Length > 0)
                        {
                            UploadFile.CreateFolder(ConfigurationManager.AppSettings[ConfigurationKeys.SAVE_BASE_FILE_PATH] + ConfigurationManager.AppSettings[ConfigurationKeys.USER_PATH] + "/" + GetLoginUser().CompanyCode + "/" + userId.ToString());
                            model.USER_INFO.user_sys_id     = userId;
                            model.USER_INFO.del_flg         = Constant.DeleteFlag.NON_DELETE;
                            model.USER_INFO.image_file_path = ConfigurationManager.AppSettings[ConfigurationKeys.USER_PATH] + "/" + GetLoginUser().CompanyCode + "/" + userId + "/" + ConfigurationManager.AppSettings[ConfigurationKeys.PROFILE_IMAGE] + file.FileName.Substring(file.FileName.LastIndexOf('.'));
                            model.USER_INFO.row_version     = this._service.GetUserInfo(GetLoginUser().CompanyCode, userId).row_version;
                            if (_service.PersonalSettingUserData(model.USER_INFO) > 0)
                            {
                                // Move image
                                UploadFile.MoveFile(ConfigurationManager.AppSettings[ConfigurationKeys.SAVE_BASE_FILE_PATH] + ConfigurationManager.AppSettings[ConfigurationKeys.TEMP_USER_PATH] + "/" +
                                                    file.FileName, ConfigurationManager.AppSettings[ConfigurationKeys.SAVE_BASE_FILE_PATH] + ConfigurationManager.AppSettings[ConfigurationKeys.USER_PATH] + "/" + GetLoginUser().CompanyCode + "/" + userId + "/" + ConfigurationManager.AppSettings[ConfigurationKeys.PROFILE_IMAGE] + file.FileName.Substring(file.FileName.LastIndexOf('.')));
                            }
                        }

                        if (sessionLogin.Password != model.USER_INFO.password &&
                            model.USER_INFO.password != Constant.DISPLAY_PASSWORD)
                        {
                            sessionLogin.Password            = model.USER_INFO.password;
                            sessionLogin.Is_expired_password = false;
                        }

                        if (sessionLogin.DisplayName != model.USER_INFO.display_name)
                        {
                            sessionLogin.DisplayName = model.USER_INFO.display_name;
                        }

                        if (sessionLogin.ImageFilePath != model.USER_INFO.image_file_path)
                        {
                            sessionLogin.ImageFilePath = model.USER_INFO.image_file_path;
                        }

                        if (sessionLogin.ActualWorkInputMode != model.USER_INFO.actual_work_input_mode)
                        {
                            sessionLogin.ActualWorkInputMode = model.USER_INFO.actual_work_input_mode;
                        }
                        SetLoginUser(sessionLogin);

                        string action  = model.USER_INFO.user_sys_id > 0 ? "更新" : "登録";
                        string message = string.Format(Resources.Messages.I007, "ユーザー情報", action);
                        model = MakePersonalSettingViewModel(userId);
                        JsonResult result = Json(
                            new
                        {
                            statusCode       = 201,
                            message          = message,
                            id               = model.USER_INFO.user_sys_id,
                            row_version      = Convert.ToBase64String(model.USER_INFO.row_version),
                            imageFilePath    = model.USER_INFO.image_file_path,
                            userNameSesssion = sessionLogin.DisplayName
                        },
                            JsonRequestBehavior.AllowGet);
                        return(result);
                    }
                    else
                    {
                        if (model.USER_INFO.user_sys_id > 0) // Duplicate action update
                        {
                            ViewBag.Duplicate = "/PMS01002/PersonalSetting";
                            string companyCode = GetLoginUser().CompanyCode;

                            model.GROUP_LIST    = this.commonService.GetUserGroupSelectList(companyCode);
                            model.POSITION_LIST = this.GetPositionList(companyCode);
                            model.LANGUAGE_LIST = this.GetLanguageList();

                            return(new EmptyResult());
                        }
                        else
                        {
                            ModelState.AddModelError("", Resources.Messages.E001);
                            return(new EmptyResult());
                        }
                    }
                }

                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);
            }
        }
Example #3
0
        public ActionResult EditCustomer(PMS02001EditViewModel model)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    HttpPostedFileBase file     = Request.Files["file"];
                    HttpPostedFileBase fileDrag = Request.Files["fileDrag"];
                    if (model.TypeUpload == "file" && file != null && file.FileName.Length > 0)
                    {
                        if (!Constant.AllowedFileExtensions.Contains(file.FileName.Substring(file.FileName.LastIndexOf('.'))))
                        {
                            ModelState.AddModelError("", String.Format(Resources.Messages.E010, "jpg,png.jpeg"));
                            return(new EmptyResult());
                        }

                        if (file.ContentLength > Constant.MaxContentLength)
                        {
                            ModelState.AddModelError("", String.Format(Resources.Messages.E021, "500KB以内"));
                            return(new EmptyResult());
                        }

                        model.CUSTOMER_INFO.logo_image_file_path = UploadFile.UploadFiles(ConfigurationManager.AppSettings[ConfigurationKeys.SAVE_BASE_FILE_PATH], file, ConfigurationManager.AppSettings[ConfigurationKeys.TEMP_CUSTOMER_PATH]);
                    }
                    else if (model.TypeUpload == "fileDrag" && fileDrag != null && fileDrag.FileName.Length > 0)
                    {
                        file = fileDrag;

                        if (!Constant.AllowedFileExtensions.Contains(file.FileName.Substring(file.FileName.LastIndexOf('.'))))
                        {
                            ModelState.AddModelError("", String.Format(Resources.Messages.E010, "jpg,png.jpeg"));
                            return(new EmptyResult());
                        }

                        if (file.ContentLength > Constant.MaxContentLength)
                        {
                            ModelState.AddModelError("", String.Format(Resources.Messages.E021, "500KB以内"));
                            return(new EmptyResult());
                        }

                        model.CUSTOMER_INFO.logo_image_file_path = UploadFile.UploadFiles(ConfigurationManager.AppSettings[ConfigurationKeys.SAVE_BASE_FILE_PATH], file, ConfigurationManager.AppSettings[ConfigurationKeys.TEMP_CUSTOMER_PATH]);
                    }
                    else
                    {
                        if (model.Clear == "1")
                        {
                            model.CUSTOMER_INFO.logo_image_file_path = string.Empty;
                        }
                    }

                    var loginUser = GetLoginUser();

                    model.CUSTOMER_INFO.upd_date     = Utility.GetCurrentDateTime();
                    model.CUSTOMER_INFO.upd_id       = loginUser.UserId;
                    model.CUSTOMER_INFO.company_code = loginUser.CompanyCode;
                    model.CUSTOMER_INFO.zip_code     = model.CUSTOMER_INFO.zip_code.Replace("-", "");

                    if (!string.IsNullOrEmpty(model.CUSTOMER_INFO.mail_address))
                    {
                        if (_service.CheckCustomerEmail(model.CUSTOMER_INFO.mail_address, model.CUSTOMER_INFO.customer_id) > 0)
                        {
                            ModelState.AddModelError("", String.Format(Resources.Messages.E008, "メールアドレス", "メールアドレス"));
                            return(new EmptyResult());
                        }
                    }

                    if ((model.CUSTOMER_INFO.customer_id == 0 ||
                         (model.OLD_DEL_FLAG &&
                          Constant.DeleteFlag.NON_DELETE.Equals(model.CUSTOMER_INFO.del_flg))) &&
                        !this.commonService.CheckValidUpdateData(loginUser.CompanyCode, Constant.LicenseDataType.CUSTOMER))
                    {
                        JsonResult result = Json(
                            new
                        {
                            statusCode = 500,
                            message    = string.Format(Resources.Messages.E067, "取引先")
                        },
                            JsonRequestBehavior.AllowGet);

                        return(result);
                    }

                    int tempcustomerID = model.CUSTOMER_INFO.customer_id;
                    int customerID     = _service.EditCustomerData(model.CUSTOMER_INFO);
                    if (customerID > 0)
                    {
                        if (file != null && file.FileName.Length > 0)
                        {
                            UploadFile.CreateFolder(ConfigurationManager.AppSettings[ConfigurationKeys.SAVE_BASE_FILE_PATH] + ConfigurationManager.AppSettings[ConfigurationKeys.CUSTOMER_PATH] + "/" + loginUser.CompanyCode + "/" + customerID.ToString());
                            model.CUSTOMER_INFO.logo_image_file_path = ConfigurationManager.AppSettings[ConfigurationKeys.CUSTOMER_PATH] + "/" + loginUser.CompanyCode + "/" + customerID + "/" + ConfigurationManager.AppSettings[ConfigurationKeys.LOGO_IMAGE] + file.FileName.Substring(file.FileName.LastIndexOf('.'));
                            model.CUSTOMER_INFO.row_version          = this._service.GetCustomerInfo(loginUser.CompanyCode, customerID).row_version;
                            model.CUSTOMER_INFO.customer_id          = customerID;

                            if (model.CUSTOMER_INFO.del_flg == null)
                            {
                                model.CUSTOMER_INFO.del_flg = Constant.DeleteFlag.NON_DELETE;
                            }

                            if (_service.EditCustomerData(model.CUSTOMER_INFO) > 0)
                            {
                                // Move image
                                UploadFile.MoveFile(ConfigurationManager.AppSettings[ConfigurationKeys.SAVE_BASE_FILE_PATH] + ConfigurationManager.AppSettings[ConfigurationKeys.TEMP_CUSTOMER_PATH] + "/" +
                                                    file.FileName, ConfigurationManager.AppSettings[ConfigurationKeys.SAVE_BASE_FILE_PATH] + ConfigurationManager.AppSettings[ConfigurationKeys.CUSTOMER_PATH] + "/" + loginUser.CompanyCode + "/" + customerID + "/" + ConfigurationManager.AppSettings[ConfigurationKeys.LOGO_IMAGE] + file.FileName.Substring(file.FileName.LastIndexOf('.')));
                            }
                        }

                        string action = Convert.ToInt32(tempcustomerID) > 0 ? "更新" : "登録";
                        //string action = model.CUSTOMER_INFO.row_version.Length > 0 ? "更新" : "登録";
                        string message = String.Format(Resources.Messages.I007, "取引先情報", action);

                        var data = this._service.GetCustomerInfo(loginUser.CompanyCode, customerID);

                        JsonResult result = Json(
                            new
                        {
                            statusCode        = 201,
                            message           = message,
                            id                = customerID,
                            row_version       = Convert.ToBase64String(data.row_version),
                            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,
                            logoImageFilePath = data.logo_image_file_path
                        },
                            JsonRequestBehavior.AllowGet);

                        return(result);
                    }
                    else
                    {
                        if (model.CUSTOMER_INFO.row_version.Length > 0) // Duplicate action update
                        {
                            JsonResult result = Json(
                                new
                            {
                                statusCode = 202,
                                message    = string.Format(Resources.Messages.E031)
                            },
                                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);
            }
        }