public ActionResult Create(ConfigurationCreateViewModel model) { try { if (!ModelState.IsValid) { AddMessageInfo("Data not complete. Please fill required field !", Enums.MessageInfoType.Error); return(RedirectToAction("Create")); } else { var data = new SYS_REFFERENCES(); if (model.ConfigText == "UPLOAD_FILE_LIMIT" || model.ConfigText == "APPROVAL_STATUS" || model.ConfigText == "HINT_COMPONENT" || model.ConfigText == "REGULATION_BRAND_REGISTRATION" || model.ConfigText == "REGULATION_EXCISE_CREDIT") { var config = configService.FindDataByType(model.ConfigText); if (model.ConfigText == "APPROVAL_STATUS" || model.ConfigText == "HINT_COMPONENT") { var tempConfig = configService.FindDataByName(model.ConfigName); data.REFF_ID = tempConfig.REFF_ID; data.REFF_TYPE = tempConfig.REFF_TYPE; data.REFF_NAME = tempConfig.REFF_NAME; data.REFF_KEYS = tempConfig.REFF_KEYS; } if (model.ConfigText == "UPLOAD_FILE_LIMIT" || model.ConfigText == "REGULATION_BRAND_REGISTRATION" || model.ConfigText == "REGULATION_EXCISE_CREDIT") { data.REFF_ID = config.REFF_ID; data.REFF_TYPE = config.REFF_TYPE; data.REFF_NAME = config.REFF_NAME; data.REFF_KEYS = config.REFF_KEYS; } data.REFF_VALUE = model.ConfigValue; data.IS_ACTIVE = model.IsActive; data.CREATED_BY = config.CREATED_BY; data.CREATED_DATE = config.CREATED_DATE; data.LASTMODIFIED_BY = CurrentUser.USER_ID; data.LASTMODIFIED_DATE = DateTime.Now; configService.UpdateSysReff(data, (int)Enums.MenuList.Configuration, (int)Enums.ActionType.Modified, (int)CurrentUser.UserRole, CurrentUser.USER_ID); AddMessageInfo("Save Configuration Succeed", Enums.MessageInfoType.Success); } else { data.REFF_TYPE = model.ConfigText; data.REFF_NAME = model.ConfigText; data.REFF_KEYS = model.ConfigText; data.REFF_VALUE = model.ConfigValue; data.CREATED_BY = CurrentUser.USER_ID; data.CREATED_DATE = DateTime.Now; data.LASTMODIFIED_BY = CurrentUser.USER_ID; data.LASTMODIFIED_DATE = DateTime.Now; data.IS_ACTIVE = model.IsActive; configService.CreateSysReff(data, (int)Enums.MenuList.Configuration, (int)Enums.ActionType.Created, (int)CurrentUser.UserRole, CurrentUser.USER_ID); AddMessageInfo("Save Configuration Succeed", Enums.MessageInfoType.Success); } } } catch (Exception ex) { AddMessageInfo("Save Failed : " + ex.Message, Enums.MessageInfoType.Error); } return(RedirectToAction("Index")); }