public ActionResult UpdateImage() { HomepageCMSModel cmsModel = new HomepageCMSModel(); cmsModel = _homepageCMSService.GetAll().First(x => x.Category == "2"); return(View(cmsModel)); }
public async Task <IActionResult> UpdateImage(IFormFile image, string typeUpload = "", int Id = 0) { try { if (ModelState.IsValid) { bool isValidType = false; if (image?.Length > 0) { string fileName = image.FileName; string extension = Path.GetExtension(fileName).ToLower(); if (extension == ".png" || extension == ".jpg" || extension == ".jpeg" || extension == ".gif") { isValidType = true; } if (!isValidType) { ModelState.AddModelError("Banner", Model.Resources.ValidationMessages.WrongFileType); return(Json(false, new JsonSerializerSettings())); } HomepageCMSModel homepageCMS = new HomepageCMSModel(); //homepageCMS.ImageName = "mobile_"+fileName; homepageCMS.Banner = image; homepageCMS.Category = "2"; await _portfolioService.UpdatePortfolioImage(homepageCMS, typeUpload, Id); } } } catch (Exception ex) { throw ex; } return(RedirectToAction("Index", "SettingsCMS")); }
public async Task <IActionResult> AddBanner([FromBody] HomepageCMSModel homepageCMSModel) { try { if (ModelState.IsValid) { bool isValidType = false; if (homepageCMSModel.Banner?.Length > 0) { string fileName = homepageCMSModel.Banner.FileName; string extension = Path.GetExtension(fileName).ToLower(); if (extension == ".png" || extension == ".jpg" || extension == ".jpeg" || extension == ".gif") { isValidType = true; } if (!isValidType) { ModelState.AddModelError("Banner", Model.Resources.ValidationMessages.WrongFileType); return(Json(false, new JsonSerializerSettings())); } homepageCMSModel.ImageName = fileName; } await _homepageCMSService.AddImageConfiguration(homepageCMSModel); } } catch (Exception ex) { throw ex; } return(RedirectToAction(nameof(HomepageCMSController.Index))); }
public IActionResult Index() { HomepageCMSModel cmsModel = new HomepageCMSModel(); cmsModel.HomepageModels = _homepageCMSService.GetAll(); return(View(cmsModel)); }
public SettingCMSModel() { HomepageCMSModel = new HomepageCMSModel(); GenericIntroducingSettingModel = new GenericIntroducingSettingModel(); ContactCMSModel = new ContactCMSModel(); InvestmentTargetSettingModel = new ListInvestmentTargetSettingModel(); ListWithdrawFee = new ListWithdrawFee(); ListMaintainingFee = new ListMaintainingFee(); HasError = false; }
public async Task UpdatePortfolioImage(HomepageCMSModel model, string typeUpload = "", int Id = 0) { try { HomepageCMS data = _mapper.Map <HomepageCMS>(model); await _portfolioManager.UpdatePortfolioImage(data, typeUpload, Id); } catch (Exception ex) { throw ex; } }
public async Task UpdateHomepageConfiguration(HomepageCMSModel homepageCMS, int category = 0, string typeUpload = "", int Id = 0) { try { var homepageCMSDto = _mapper.Map <HomepageCMSModel, HomepageCMS>(homepageCMS); await _homepageCMSManager.UpdateHomepageConfiguration(homepageCMSDto, category, typeUpload, Id); } catch (Exception ex) { throw ex; } }
public async Task AddImageConfiguration(HomepageCMSModel homepageCMS, string typeUpload = "") { try { HomepageCMS model = _mapper.Map <HomepageCMS>(homepageCMS); await _homepageCMSManager.AddImageConfiguration(model, typeUpload); } catch (Exception ex) { throw ex; } }
public async Task <IActionResult> UpdateBanner(IFormFile image, int category = 0, string typeUpload = "", int Id = 0, int isAdd = 0) { try { if (ModelState.IsValid) { bool isValidType = false; if (image.Length > 0) { string fileName = image.FileName; string extension = Path.GetExtension(fileName).ToLower(); if (extension == ".png" || extension == ".jpg" || extension == ".jpeg" || extension == ".gif") { isValidType = true; } if (!isValidType) { ModelState.AddModelError("Banner", Model.Resources.ValidationMessages.WrongFileType); return(Json(false, new JsonSerializerSettings())); } HomepageCMSModel homepageCMS = new HomepageCMSModel(); homepageCMS.Banner = image; homepageCMS.Category = category.ToString(); if (isAdd != 1) { await _homepageCMSService.UpdateHomepageConfiguration(homepageCMS, category, typeUpload, Id); } else { await _homepageCMSService.AddImageConfiguration(homepageCMS, typeUpload); } } //await _homepageCMSService.UpdateHomepageConfiguration(homepageCMSModel); } } catch (Exception ex) { throw ex; } return(RedirectToAction("Index", "SettingsCMS")); }