Exemplo n.º 1
0
        public async Task <IActionResult> AddPaymentSchedule(int templateId)
        {
            Template template = _templateServiceService.FindTemplateById(templateId);
            PaymentScheduleViewModel model = new PaymentScheduleViewModel
            {
                DateStart     = DateTime.Now.AddDays(1),
                TemplateName  = template.TempalteName,
                IntervalTypes = selectListService.GetIntervalTypes(),
                TemplateId    = template.Id
            };

            return(View(model));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> AddPaymentSchedule(PaymentScheduleViewModel model)
        {
            validationService.ValidateAddPaymentSchedule(model, ModelState);
            Template template = _templateServiceService.FindTemplateById(model.TemplateId);

            if (ModelState.IsValid)
            {
                IntervalType interval =
                    await paymentScheduleService.FindIntervalTypeByIntervalCode(model.IntervalCode.Value);

                paymentScheduleService.CreatePaymentSchedule(template, interval,
                                                             model.DateStart,
                                                             model.DateEnd);
                return(RedirectToAction("Index", "Template"));
            }
            model.IntervalTypes = selectListService.GetIntervalTypes();
            model.TemplateName  = template.TempalteName;
            return(View(model));
        }
Exemplo n.º 3
0
        public ModelStateDictionary ValidateAddPaymentSchedule(PaymentScheduleViewModel model, ModelStateDictionary ModelState)
        {
            DateTime finishDate;

            if (model.IntervalCode == 0)
            {
                ModelState.AddModelError("IntervalCode", "*Выберите интервал проведения платежа!");
            }
            if (model.DateStart < DateTime.Now.Date.AddDays(1))
            {
                ModelState.AddModelError("DateStart", string.Format("*Первоначальное выполнение платежа доступно только c {0}", DateTime.Now.AddDays(1).ToString("d")));
            }
            if (DateTime.TryParse(model.DateEnd, out finishDate) && finishDate < model.DateStart)
            {
                ModelState.AddModelError("DateEnd", "*Дата окончания должна быть больше даты начала!");
            }

            return(ModelState);
        }
Exemplo n.º 4
0
 public PaymentSchedule()
 {
     InitializeComponent();
     _viewModel  = (PaymentScheduleViewModel)LayoutRoot.DataContext;
     DataContext = _viewModel;
 }