public ActionResult AddDataLanguage(List <MasterDataModel> listData) { MasterDataViewModel masterData = new MasterDataViewModel(); if (listData == null) { listData = new List <MasterDataModel>(); } listData.Add(new MasterDataModel() { Name = string.Empty, Description = string.Empty, Abbreviations = string.Empty, Value = string.Empty }); //list language var localizationService = EngineContext.Current.Resolve <ILocalizationService>(); var responseLanguage = localizationService.GetLanguage(); if (responseLanguage != null) { var resultLanguage = JsonConvert.DeserializeObject <HrmResultModel <LanguageModel> >(responseLanguage); if (!CheckPermission(resultLanguage)) { //return to Access Denied } else { masterData.Languages = JsonConvert.DeserializeObject <List <dynamic> >(JsonConvert.SerializeObject(resultLanguage.Results)); } } masterData.ListMasterDataByLanguage = JsonConvert.DeserializeObject <List <dynamic> >(JsonConvert.SerializeObject(listData)); return(PartialView("~/Administration/Views/MasterData/_ListMasterDataByLanguage.cshtml", masterData)); }
public ActionResult ShowFormAddMasterData(long groupId = 0) { MasterDataViewModel MasterData = new MasterDataViewModel(); List <MasterDataModel> ListMasterData = new List <MasterDataModel>(); MasterData.GroupId = groupId; //list language var localizationService = EngineContext.Current.Resolve <ILocalizationService>(); var responseLanguage = localizationService.GetLanguage(); if (responseLanguage != null) { var resultLanguage = JsonConvert.DeserializeObject <HrmResultModel <LanguageModel> >(responseLanguage); if (!CheckPermission(resultLanguage)) { //return to Access Denied } else { MasterData.Languages = JsonConvert.DeserializeObject <List <dynamic> >(JsonConvert.SerializeObject(resultLanguage.Results)); } } ListMasterData.Add(new MasterDataModel() { Name = string.Empty, Description = string.Empty, Abbreviations = string.Empty, Value = string.Empty }); MasterData.MasterData = new MasterDataModel(); MasterData.MasterData.IsDisbleEditing = true; MasterData.ListMasterDataByLanguage = JsonConvert.DeserializeObject <List <dynamic> >(JsonConvert.SerializeObject(ListMasterData)); return(PartialView("~/Administration/Views/MasterData/_AddMasterData.cshtml", MasterData)); }
public View(MasterDataViewModel viewModel) { InitializeComponent(); this.viewModel = viewModel; this.DataContext = viewModel; this.Loaded += View_Loaded; }
public ActionResult Index() { MasterDataViewModel masterData = new MasterDataViewModel(); var resultTableConfig = this._tableConfigService.GetTableConfigByTableName(TableConfig.MasterData); var responseTableConfig = JsonConvert.DeserializeObject <HrmResultModel <TableConfigModel> >(resultTableConfig); var dataTableConfig = JsonConvert.DeserializeObject <TableViewModel>(responseTableConfig.Results[0].ConfigData); List <MasterDataModel> list = new List <MasterDataModel>(); var resultMasterDataGroupId = this._masterDataService.GetAllMasterDataByGroupId(0); if (resultMasterDataGroupId != null) { var response = JsonConvert.DeserializeObject <HrmResultModel <MasterDataModel> >(resultMasterDataGroupId); if (!CheckPermission(response)) { //return to Access Denied } else { masterData.MasterDatas = response.Results; } } //list language var localizationService = EngineContext.Current.Resolve <ILocalizationService>(); var responseLanguage = localizationService.GetLanguage(); if (responseLanguage != null) { var resultLanguage = JsonConvert.DeserializeObject <HrmResultModel <LanguageModel> >(responseLanguage); if (!CheckPermission(resultLanguage)) { //return to Access Denied } else { masterData.Languages = JsonConvert.DeserializeObject <List <dynamic> >(JsonConvert.SerializeObject(resultLanguage.Results)); } } //model param var param = new BasicParamModel() { FilterField = string.Empty, PageNumber = 1, PageSize = dataTableConfig.ItemsPerPage, LanguageId = _languageId, RoleId = _roleId, UserId = _userId, DbName = CurrentUser.DbName }; dataTableConfig.TableConfigName = TableConfig.MasterData; //for reload and filter case dataTableConfig.TableReloadConfigUrl = TableReloadUrl.TableMasterDataReloadUrl; // for show hide column case masterData.Table = RenderTable(dataTableConfig, param, TableName.TableMasterData, Convert.ToInt32(masterData.MasterDatas[0].Id)); masterData.GroupId = masterData.MasterDatas[0].Id; return(View(masterData)); }
public static MultiDropDownItem ConvertToMultiDropDownItem(this MasterDataViewModel model) { var item = new MultiDropDownItem() { Value = model.MasterId.ToString(), Text = model.GetLocalizedName() }; return(item); }
public static SelectListItem ConvertCodeToSelectListItems(this MasterDataViewModel item) { var result = new SelectListItem() { Value = item.MasterId.ToString(), Text = item.Code }; return(result); }
public JsonResult SaveMasterData(MasterDataViewModel model) { return(ExecuteFunctionRun(() => { ActionResult result = new ActionResult(); OThinker.H3.Data.EnumerableMetadata data = null; bool success = false; string msg = string.Empty; if (!string.IsNullOrEmpty(model.ObjectID)) { data = this.Engine.MetadataRepository.GetById(model.ObjectID); data.SortKey = model.SortKey; data.EnumValue = model.DisplayText; data.IsDefault = model.IsDefault; success = this.Engine.MetadataRepository.Update(data); } else { //判断对象是否已经存在 if (this.Engine.MetadataRepository.GetByCode(model.Category, model.Code) != null) { success = false; msg = "msgGlobalString.CodeDuplicate"; } else { data = new OThinker.H3.Data.EnumerableMetadata() { Category = model.Category, Code = model.Code, EnumValue = model.DisplayText, SortKey = model.SortKey, IsDefault = model.IsDefault }; success = this.Engine.MetadataRepository.Add(data); } } result.Success = success; if (!success) { result.Message = (msg == string.Empty ? "msgGlobalString.SaveFailed" : msg); } else { var category = GetCategoryList(); result.Extend = new { data = category, initValue = model.Category, initText = model.Category }; } return Json(result, JsonRequestBehavior.AllowGet); })); }
public static MasterDataViewModel GetMasterTableData() { List <QualificationModel> qualificationList = GetQualifications(); List <listItem> qualifications = new List <listItem>(); foreach (QualificationModel qualificationModel in qualificationList) { listItem selectlistitem = new listItem { Text = qualificationModel.Qualification, Value = qualificationModel.Id.ToString() }; qualifications.Add(selectlistitem); } List <DepartmentModel> departmentList = GetDepartments(); List <listItem> departments = new List <listItem>(); foreach (DepartmentModel departmentModel in departmentList) { listItem selectlistitem = new listItem { Text = departmentModel.Department, Value = departmentModel.Id.ToString() }; departments.Add(selectlistitem); } List <CountryModel> countryList = GetCountries(); List <listItem> countries = new List <listItem>(); foreach (CountryModel countryModel in countryList) { listItem selectlistitem = new listItem { Text = countryModel.CountryName, Value = countryModel.Id.ToString() }; countries.Add(selectlistitem); } var data = new MasterDataViewModel { QualificationList = qualifications, DepartmentList = departments, CountryList = countries }; return(data); }
public static SelectListItem ConvertToSelectListItems(this MasterDataViewModel item, string language = null, bool code = false) { if (language == null) { language = Localization.CurrentLanguage; } var result = new SelectListItem() { Value = item.MasterId.ToString(), Text = code ? item.Code : item.GetLocalizedName(language) }; return(result); }
public JsonResult GetMasterData(string id) { return(ExecuteFunctionRun(() => { //返回全局变量实例 var item = this.Engine.MetadataRepository.GetById(id);// .GlobalDataManager.GetItem(ItemName); MasterDataViewModel model = null; if (item != null) { model = new MasterDataViewModel() { ObjectID = item.ObjectID, Category = item.Category, Code = item.Code, DisplayText = item.EnumValue, IsDefault = item.IsDefault, SortKey = item.SortKey }; } return Json(model, JsonRequestBehavior.AllowGet); })); }
public ActionResult RemoveDataLanguage(int index, List <MasterDataModel> listData) { MasterDataViewModel masterData = new MasterDataViewModel(); listData.RemoveAt(index); //list language var localizationService = EngineContext.Current.Resolve <ILocalizationService>(); var responseLanguage = localizationService.GetLanguage(); if (responseLanguage != null) { var resultLanguage = JsonConvert.DeserializeObject <HrmResultModel <LanguageModel> >(responseLanguage); if (!CheckPermission(resultLanguage)) { //return to Access Denied } else { masterData.Languages = JsonConvert.DeserializeObject <List <dynamic> >(JsonConvert.SerializeObject(resultLanguage.Results)); } } masterData.ListMasterDataByLanguage = JsonConvert.DeserializeObject <List <dynamic> >(JsonConvert.SerializeObject(listData)); return(PartialView("~/Administration/Views/MasterData/_ListMasterDataByLanguage.cshtml", masterData)); }
public ActionResult ShowFormEditMasterData(long id) { MasterDataViewModel masterData = new MasterDataViewModel(); List <MasterDataModel> ListMasterData = new List <MasterDataModel>(); List <LanguageModel> languages = new List <LanguageModel>(); //list language var localizationService = EngineContext.Current.Resolve <ILocalizationService>(); var responseLanguage = localizationService.GetLanguage(); if (responseLanguage != null) { var resultLanguage = JsonConvert.DeserializeObject <HrmResultModel <LanguageModel> >(responseLanguage); if (!CheckPermission(resultLanguage)) { //return to Access Denied } else { languages = resultLanguage.Results; masterData.Languages = JsonConvert.DeserializeObject <List <dynamic> >(JsonConvert.SerializeObject(resultLanguage.Results)); } } var responseMasterData = _masterDataService.GetMasterDataById(id); if (responseMasterData != null) { var result = JsonConvert.DeserializeObject <HrmResultModel <MasterDataModel> >(responseMasterData); if (!CheckPermission(result)) { //return to Access Denied } else { masterData.MasterData = result.Results[0]; masterData.GroupId = result.Results[0].GroupId; } } var responseMasterDatas = localizationService.GetLocalizedDataByDataId(id, DataType.MasterData); List <LocalizedDataModel> LocalizedDatas = new List <LocalizedDataModel>(); if (responseMasterDatas != null) { var resultMasterDatas = JsonConvert.DeserializeObject <HrmResultModel <LocalizedDataModel> >(responseMasterDatas); if (!CheckPermission(resultMasterDatas)) { //return to Access Denied } else { LocalizedDatas = resultMasterDatas.Results; var listProp = localizationService.GetMultipleLanguageConfiguration(DataType.MasterData); var listData = new List <MasterDataModel>(); foreach (var language in languages) { var data = LocalizedDatas.Where(s => s.LanguageId == language.Id).ToList(); if (data != null && data.Count() > 0) { MasterDataModel MasterData = new MasterDataModel(); var response = FunctionHelpers.ConvertLanguageToModel(data, MasterData, listProp.Results); response.LanguageId = language.Id; ListMasterData.Add(response); } } } } masterData.ListMasterDataByLanguage = JsonConvert.DeserializeObject <List <dynamic> >(JsonConvert.SerializeObject(ListMasterData)); return(PartialView("~/Administration/Views/MasterData/_AddMasterData.cshtml", masterData)); }