コード例 #1
0
        public ActionResult UpdateImage()
        {
            HomepageCMSModel cmsModel = new HomepageCMSModel();

            cmsModel = _homepageCMSService.GetAll().First(x => x.Category == "2");
            return(View(cmsModel));
        }
コード例 #2
0
        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"));
        }
コード例 #3
0
        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)));
        }
コード例 #4
0
        public IActionResult Index()
        {
            HomepageCMSModel cmsModel = new HomepageCMSModel();

            cmsModel.HomepageModels = _homepageCMSService.GetAll();
            return(View(cmsModel));
        }
コード例 #5
0
ファイル: SettingCMSModel.cs プロジェクト: noname9xndz/fund21
 public SettingCMSModel()
 {
     HomepageCMSModel = new HomepageCMSModel();
     GenericIntroducingSettingModel = new GenericIntroducingSettingModel();
     ContactCMSModel = new ContactCMSModel();
     InvestmentTargetSettingModel = new ListInvestmentTargetSettingModel();
     ListWithdrawFee    = new ListWithdrawFee();
     ListMaintainingFee = new ListMaintainingFee();
     HasError           = false;
 }
コード例 #6
0
 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;
     }
 }
コード例 #7
0
 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;
     }
 }
コード例 #8
0
 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;
     }
 }
コード例 #9
0
        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"));
        }