protected override async Task ActionAsync() { await UserSecurity.CheckAdministratorAsync(_userService, Input.UserId, Input.Data.Site.SiteId); var itemDataModel = await GetMasterItemDataModelAsync(_dataFactory, Input.Data.Site.SiteId, true); if (itemDataModel == null) { itemDataModel = new ItemDataModel(); itemDataModel.SiteId = Input.Data.Site.SiteId; itemDataModel.ParentId = Input.Data.Site.SiteId; itemDataModel.PropertyName = "Master"; itemDataModel.Module = "Master"; itemDataModel.Index = 100; // TODO _dataFactory.Add(itemDataModel); } var elements = await SaveFreeCommand.GetElementsAsync(_dataFactory, itemDataModel, Input.Data.Elements); // On enregistre l'element var freeBusinessModel = new MasterBusinessModel(); freeBusinessModel.Elements = elements; itemDataModel.Data = freeBusinessModel; await _dataFactory.SaveChangeAsync(); await _cacheProvider.UpdateCacheAsync(Input.Data.Site.SiteId); Result.Data = await _moduleManager.GetMasterAsync(Input.Data.Site); }
private IList <DataFileInput> GetImages(MasterBusinessModel moduleFree, string propertyName) { var element = moduleFree.Elements.FirstOrDefault(e => e.Property == propertyName); if (element == null || string.IsNullOrEmpty(element.Data)) { return(null); } return(JsonConvert.DeserializeObject <List <DataFileInput> >(element.Data)); }
private static string GetData(MasterBusinessModel moduleFree, string property, string defaultData = null) { var element = moduleFree.Elements.FirstOrDefault(e => e.Property == property); string color = defaultData; if (element != null && !string.IsNullOrEmpty(element.Data)) { color = element.Data; } return(color); }