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 <IActionResult> Edit(ListWithdrawFee model)
        {
            List <WithdrawFeeModel> newFees     = new List <WithdrawFeeModel>();
            List <WithdrawFeeModel> existedFees = new List <WithdrawFeeModel>();
            bool isValid = true;

            if (model.QuickWithdrawFee.Percentage != 0)
            {
                model.ListFees.Add(model.QuickWithdrawFee);
            }
            else
            {
                isValid = false;
                TempData["Error_WithdrawFee"] = ValidationMessages.QuickWithdrawalIsEmpty;
                return(ReturnWithError(model));
            }

            foreach (var item in model.ListFees)
            {
                if (item.TimeInvestmentBegin >= item.TimeInvestmentEnd)
                {
                    isValid = false;
                    TempData["Error_WithdrawFee"] = ValidationMessages.CompareMonthFromMonthTo;
                    return(ReturnWithError(model));
                }
                else
                {
                    var dataExisted = CheckDataExisted(item.Id).Result;
                    if (!dataExisted)
                    {
                        newFees.Add(item);
                    }
                    else
                    {
                        existedFees.Add(item);
                    }
                }
            }

            if (newFees.Count > 0)
            {
                await _withdrawFeeService.AddListFees(newFees);
            }
            if (existedFees.Count > 0)
            {
                await _withdrawFeeService.UpdateConfigurations(existedFees);
            }
            return(RedirectToAction("Index", "SettingsCMS"));
        }
        public IActionResult ReturnWithError(ListWithdrawFee model)
        {
            SettingCMSModel settingCMSModel = new SettingCMSModel();

            settingCMSModel.ListMaintainingFee                      = _maintainingFeeService.GetConfiguration();
            settingCMSModel.ListWithdrawFee                         = model;
            settingCMSModel.ContactCMSModel                         = _contactConfigurationService.GetContactConfiguration();
            settingCMSModel.GenericIntroducingSettingModel          = _introducingSettingService.GetSetting();
            settingCMSModel.InvestmentTargetSettingModel.ListModels = _investmentTargetCMSService.GetAll();
            settingCMSModel.HomepageCMSModel.HomepageModels         = _homepageCMSService.GetAll();
            ViewBag.ListPortfolio = _portfolioService.GetAllPortfolio().ToList();
            ViewBag.Data          = _investmentTargetCMSService.GetAll().ToList();

            return(View("Views/SettingsCMS/Index.cshtml", settingCMSModel));
        }
Exemple #4
0
        public async Task <ListWithdrawFee> GetConfiguration()
        {
            try
            {
                List <WithdrawalFee> modelDTO = _withdrawFeeManager.GetConfiguration();
                var list = _mapper.Map <List <WithdrawFeeModel> >(modelDTO);

                ListWithdrawFee item = new ListWithdrawFee();
                item.ListFees         = list;
                item.QuickWithdrawFee = _mapper.Map <WithdrawFeeModel>(await _withdrawFeeManager.GetQuickWithdrawalFeeItem());
                return(item);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }