public void AddNewApp(AjaxAppProperties postData) { try { DBEntities context = COREobject.i.Context; var newApp = new Application { Name = postData.DisplayName.RemoveDiacritics(), DisplayName = postData.DisplayName, TileWidth = postData.TileWidth, TileHeight = postData.TileHeight, Color = postData.Color, Icon = postData.Icon }; context.Applications.Add(newApp); context.SaveChanges(); var newRootMetablock = new TapestryDesignerMetablock { Name = "Root metablock", ParentApp = newApp }; context.TapestryDesignerMetablocks.Add(newRootMetablock); context.SaveChanges(); } catch (Exception ex) { string errorMessage = $"App manager: error creating new application (POST api/master/apps). Exception message: {ex.Message}"; throw GetHttpInternalServerErrorResponseException(errorMessage); } }
public AjaxAppProperties LoadAppProperties(int appId) { try { DBEntities context = COREobject.i.Context; Application app = context.Applications.Include("CSSTemplate").FirstOrDefault(a => a.Id == appId); AjaxAppProperties result = new AjaxAppProperties { Id = app.Id, DisplayName = app.DisplayName, TileWidth = app.TileWidth, TileHeight = app.TileHeight, Color = app.Color, Icon = app.Icon, IsAllowedForAll = app.IsAllowedForAll, IsAllowedGuests = app.IsAllowedGuests }; return(result); } catch (Exception ex) { string errorMessage = $"App manager: error loading app properties (GET api/master/apps/{appId}/properties). Exception message: {ex.Message}"; throw GetHttpInternalServerErrorResponseException(errorMessage); } }
public void SaveAppProperties(int appId, AjaxAppProperties postData) { try { DBEntities context = COREobject.i.Context; Application app = context.Applications.Where(a => a.Id == appId).First(); app.DisplayName = postData.DisplayName; app.TileWidth = postData.TileWidth; app.TileHeight = postData.TileHeight; app.Color = postData.Color; app.Icon = postData.Icon; app.IsAllowedForAll = postData.IsAllowedForAll; app.IsAllowedGuests = postData.IsAllowedGuests; context.SaveChanges(); } catch (Exception ex) { string errorMessage = $"App manager: error changing app properties (POST api/master/apps/{appId}/properties) Exception message: {ex.Message}"; throw GetHttpInternalServerErrorResponseException(errorMessage); } }