public async Task <IActionResult> SystemCommunicationsSave(int id) { var app = await GetApplicationAsync(id); if (app == null) { return(NotFound()); } var model = SystemCommunicationsModel.Create(app.AppSettings.CreativeIdBySystemCommunicationPurpose); foreach (var key in this.Request.Form.Keys) { SystemCommunicationPurposes purpose; if (!Enum.TryParse(key.RightOf("CreativeIdFor_"), out purpose)) { continue; } var scm = model.FirstOrDefault(z => z.Purpose == purpose); if (scm == null) { continue; } int creativeId; int.TryParse(this.Request.Form[key], out creativeId); scm.CreativeId = creativeId; } app.AppSettings.CreativeIdBySystemCommunicationPurpose = model.ToDictionary(z => z.Purpose, z => z.CreativeId); Rdb.Update(app); await Rdb.SaveChangesAsync(); SetToast(AspHelpers.ToastMessages.Saved); return(RedirectToIndex()); }
public async Task <IActionResult> SystemCommunications(int id) { var app = await GetApplicationAsync(id); if (app == null) { return(NotFound()); } PopulateViewBagWithCreativeSelectListItemsByCommunicationModel(app.TenantId); SetHeroLayoutViewData(app, PageKeys.SystemCommunications); var model = SystemCommunicationsModel.Create(app.AppSettings.CreativeIdBySystemCommunicationPurpose); return(View(ViewNames.SystemCommunications, model)); }