public IActionResult SetNewFrameworkBrand(string actionname, int frameworkId = 0) { var adminId = GetAdminId(); var centreId = GetCentreId(); DetailFramework?framework; if (actionname == "New") { if (TempData[MultiPageFormDataFeature.AddNewFramework.TempDataKey] == null) { return(StatusCode((int)HttpStatusCode.NotFound)); } var sessionNewFramework = multiPageFormService.GetMultiPageFormData <SessionNewFramework>( MultiPageFormDataFeature.AddNewFramework, TempData ); framework = sessionNewFramework.DetailFramework; multiPageFormService.SetMultiPageFormData( sessionNewFramework, MultiPageFormDataFeature.AddNewFramework, TempData ); } else { framework = frameworkService.GetDetailFrameworkByFrameworkId(frameworkId, adminId); if (framework == null | centreId == null) { logger.LogWarning( $"Failed to load branding page for frameworkID: {frameworkId} adminId: {adminId}, centreId: {centreId}" ); return(StatusCode(500)); } if (framework.UserRole < 2) { return(StatusCode(403)); } } if (centreId == null) { return(StatusCode(404)); } var brandsList = commonService.GetBrandListForCentre((int)centreId).Select(b => new { b.BrandID, b.BrandName }).ToList(); var categoryList = commonService.GetCategoryListForCentre((int)centreId).Select(c => new { c.CourseCategoryID, c.CategoryName }).ToList(); var topicList = commonService.GetTopicListForCentre((int)centreId).Select(t => new { t.CourseTopicID, t.CourseTopic }).ToList(); var brandSelectList = new SelectList(brandsList, "BrandID", "BrandName"); var categorySelectList = new SelectList(categoryList, "CourseCategoryID", "CategoryName"); var topicSelectList = new SelectList(topicList, "CourseTopicID", "CourseTopic"); var model = new BrandingViewModel() { DetailFramework = framework, BrandSelectList = brandSelectList, CategorySelectList = categorySelectList, TopicSelectList = topicSelectList }; return(View("Developer/Branding", model)); }
public ActionResult Branding(BrandingViewModel model) { AntiForgery.Validate(); if (ModelState.IsValid) { // Get the original branding settings BrandingSettings original = PnPPartnerPackUtilities.GetTenantBrandingSettings(); // If something changed in the branding settings compared with previous settings if (model.LogoImageUrl != original.LogoImageUrl || model.BackgroundImageUrl != original.BackgroundImageUrl || model.ColorFileUrl != original.ColorFileUrl || model.FontFileUrl != original.FontFileUrl || model.CSSOverrideUrl != original.CSSOverrideUrl || model.UICustomActionsUrl != original.UICustomActionsUrl) { var newBrandingSettings = new BrandingSettings { LogoImageUrl = model.LogoImageUrl, BackgroundImageUrl = model.BackgroundImageUrl, ColorFileUrl = model.ColorFileUrl, FontFileUrl = model.FontFileUrl, CSSOverrideUrl = model.CSSOverrideUrl, UICustomActionsUrl = model.UICustomActionsUrl, UpdatedOn = DateTime.Now, }; // Update the last date and time of update model.UpdatedOn = newBrandingSettings.UpdatedOn; // Get the JSON representation of the settings var jsonBranding = JsonConvert.SerializeObject(newBrandingSettings); // Store the new tenant-wide settings in the Infrastructural Site Collection PnPPartnerPackUtilities.SetPropertyBagValueToInfrastructure( PnPPartnerPackConstants.PropertyBag_Branding, jsonBranding); } if (model.RollOut) { // Create the asynchronous job var job = new BrandingJob { Owner = ClaimsPrincipal.Current.Identity.Name, Title = "Tenant Wide Branding", }; // Enqueue the job for execution model.JobId = ProvisioningRepositoryFactory.Current.EnqueueProvisioningJob(job); } } return View(model); }
public ActionResult Branding(BrandingViewModel model) { AntiForgery.Validate(); if (ModelState.IsValid) { // Get the original branding settings BrandingSettings original = PnPPartnerPackUtilities.GetTenantBrandingSettings(); // If something changed in the branding settings compared with previous settings if (model.LogoImageUrl != original.LogoImageUrl || model.BackgroundImageUrl != original.BackgroundImageUrl || model.ColorFileUrl != original.ColorFileUrl || model.FontFileUrl != original.FontFileUrl || model.CSSOverrideUrl != original.CSSOverrideUrl || model.UICustomActionsUrl != original.UICustomActionsUrl) { var newBrandingSettings = new BrandingSettings { LogoImageUrl = model.LogoImageUrl, BackgroundImageUrl = model.BackgroundImageUrl, ColorFileUrl = model.ColorFileUrl, FontFileUrl = model.FontFileUrl, CSSOverrideUrl = model.CSSOverrideUrl, UICustomActionsUrl = model.UICustomActionsUrl, UpdatedOn = DateTime.Now, }; // Update the last date and time of update model.UpdatedOn = newBrandingSettings.UpdatedOn; // Get the JSON representation of the settings var jsonBranding = JsonConvert.SerializeObject(newBrandingSettings); // Store the new tenant-wide settings in the Infrastructural Site Collection PnPPartnerPackUtilities.SetPropertyBagValueToInfrastructure( PnPPartnerPackConstants.PropertyBag_Branding, jsonBranding); } if (model.RollOut) { // Create the asynchronous job var job = new BrandingJob { Owner = ClaimsPrincipal.Current.Identity.Name, Title = "Tenant Wide Branding", }; // Enqueue the job for execution model.JobId = ProvisioningRepositoryFactory.Current.EnqueueProvisioningJob(job); } } return(View(model)); }
public async Task <ActionResult> Edit() { BrandingViewModel model = new BrandingViewModel(); model.ResponseStatus = false; try { HttpResponseMessage response = await Get("Branding/GetAll"); if (response.IsSuccessStatusCode) { var responseContent = await response.Content.ReadAsAsync <SOBrandingDto>(); if (response.StatusCode == HttpStatusCode.OK && responseContent != null) { model = brandMapper.ToObject(responseContent); model.ResponseStatus = true; } } model.ResponseMsg = response.ReasonPhrase; response = await Get("SPCurrency/GetAllCurrency"); if (response.IsSuccessStatusCode) { var responseContent = await response.Content.ReadAsAsync <List <SPCurrencyDto> >(); if (response.StatusCode == HttpStatusCode.OK && responseContent.Count() > 0) { model.BaseCurrencyList = responseContent.AsEnumerable().Select(s => new SelectListItem() { Text = s.Currency, Value = s.Id.ToString(), Selected = s.Id == model.BaseCurrencyID }); } else { model.BaseCurrencyList = new List <SelectListItem>(); } } else { model.BaseCurrencyList = new List <SelectListItem>(); } } catch (Exception ex) { logger.Error("Branding- Edit " + ex.Message); } return(View(model)); }
public async Task <ActionResult> ViewBranding() { BrandingViewModel model = new BrandingViewModel(); model.ResponseStatus = false; HttpResponseMessage response = null; try { using (response = await Get("Branding/GetAll")) { if (response.IsSuccessStatusCode) { var responseContent = await response.Content.ReadAsAsync <SOBrandingDto>(); if (response.StatusCode == HttpStatusCode.OK && responseContent != null) { model = brandMapper.ToObject(responseContent); model.ResponseStatus = true; } } model.ResponseMsg = response.ReasonPhrase; } using (response = await Get("SPCurrency/GetCurrencyById/" + model.BaseCurrencyID)) { if (response.IsSuccessStatusCode) { var responseContent = await response.Content.ReadAsAsync <SPCurrencyDto>(); if (response.StatusCode == HttpStatusCode.OK && responseContent != null) { model.CurrencyName = responseContent.Currency; } else { model.CurrencyName = string.Empty; } } } } catch (Exception ex) { logger.Error(ex.Message); model.ResponseMsg = ex.Message; } return(View(model)); }
public ActionResult Branding() { BrandingSettings original = PnPPartnerPackUtilities.GetTenantBrandingSettings(); BrandingViewModel model = new BrandingViewModel { LogoImageUrl = original.LogoImageUrl, BackgroundImageUrl = original.BackgroundImageUrl, ColorFileUrl = original.ColorFileUrl, FontFileUrl = original.FontFileUrl, CSSOverrideUrl = original.CSSOverrideUrl, UICustomActionsUrl = original.UICustomActionsUrl, }; return View(model); }
public ActionResult Branding() { BrandingSettings original = PnPPartnerPackUtilities.GetTenantBrandingSettings(); BrandingViewModel model = new BrandingViewModel { LogoImageUrl = original.LogoImageUrl, BackgroundImageUrl = original.BackgroundImageUrl, ColorFileUrl = original.ColorFileUrl, FontFileUrl = original.FontFileUrl, CSSOverrideUrl = original.CSSOverrideUrl, UICustomActionsUrl = original.UICustomActionsUrl, }; return(View(model)); }
public async Task <ActionResult> Edit(BrandingViewModel model) { HttpResponseMessage response = null; model.ResponseStatus = false; try { if (model.Id > 0) { response = await Put("Branding/Update", brandMapper.ToEntity(model)); if (response.IsSuccessStatusCode) { if (response.StatusCode == HttpStatusCode.OK) { model.ResponseStatus = true; } } model.ResponseMsg = response.ReasonPhrase; } else { response = await Post("Branding/Create", brandMapper.ToEntity(model)); model.ResponseMsg = response.ReasonPhrase; if (response.IsSuccessStatusCode) { if (response.StatusCode == HttpStatusCode.Created) { model.ResponseStatus = true; } } } return(Json(model.ResponseStatus, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { logger.Error("Branding- Edit Post" + ex.Message); } return(View("Edit")); }