public void AddRegularPayment(RegularPayment regularPayment)
 {
     /*RegularPayment rp = regularPayment as RegularPayment;
      * if (rp == null)
      *  return false;*/
     EntityWrapper.AddRegularPayment(regularPayment);
 }
        public ActionResult Edit(RegularPaymentEditModel input)
        {
            if (ModelState.IsValid)
            {
                RegularPayment regularPayment = db.RegularPayments.Find(input.RegularPaymentId);
                if (regularPayment == null)
                {
                    ModelState.AddModelError("", "Не найден регулярный платеж");
                    return(View(input));
                }
                else if ((input.PayoutFrom == null && input.PayoutTo == null) || input.Sum == 0)
                {
                    ModelState.AddModelError("", "Ошибка ввода");
                    return(View(input));
                }
                else
                {
                    regularPayment.Sum        = input.Sum;
                    regularPayment.PayoutFrom = input.PayoutFrom;
                    regularPayment.PayoutTo   = input.PayoutTo;
                    db.SaveChanges();

                    return(RedirectToAction("Index"));
                }
            }
            return(View(input));
        }
        public ActionResult DeleteConfirmed(int id)
        {
            RegularPayment regularPayment = db.RegularPayments.Find(id);

            db.RegularPayments.Remove(regularPayment);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 //
 public static void AddRegularPayment(RegularPayment regularPayment)
 {
     using (var context = new ATMDbContext())
     {
         regularPayment.DeleteDatabaseValues();
         context.RegularPayments.Add(regularPayment);
         context.SaveChanges();
     }
 }
        private bool CheckExpensePayment(Saldo s, RegularPayment payment)
        {
            var paymentArticle = _db.SeekAccount(payment.Article);

            return((from tr in _db.TransWithTags
                    where tr.Timestamp.IsMonthTheSame(s.StartDate) &&
                    tr.Tags != null &&
                    tr.Tags.Contains(paymentArticle)
                    select tr).FirstOrDefault() != null);
        }
Exemple #6
0
        public DateTime ShowNextPaymentData(int id)
        {
            _logger.LogInformation("ShowNextPaymentData with id {id}", id);
            RegularPayment regularPayment = GetRegularPaymentsById(id);

            if (regularPayment == null)
            {
                throw new EntityNotFoundException(typeof(RegularPayment), id);
            }
            return(regularPayment.DateOfLastPay.AddDays(regularPayment.Period));
        }
Exemple #7
0
        public ActionResult CreateRegularPayment([FromBody] RegularPayment regularPayment)
        {
            _logger.LogInformation("CreateRegularPayment method");
            if (regularPayment == null)
            {
                throw new EntityNullException(typeof(RegularPayment));
            }

            _paymentsManager.AddRegularPayment(regularPayment);
            return(Ok());
        }
        public bool CreateRegularPayment(RegularPayment regularPayment)
        {
            var sameID = GetRegularPayments().FirstOrDefault(rp => rp.PaymentID == regularPayment.PaymentID);

            if (sameID != null)
            {
                return(false);
            }
            regularpayments = regularpayments.Append(regularPayment);
            return(true);
        }
        // GET: RegularPayments/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            RegularPayment regularPayment = db.RegularPayments.Find(id);

            if (regularPayment == null)
            {
                return(HttpNotFound());
            }
            return(View(regularPayment));
        }
        public void MapRegularPaymentTest()
        {
            _calculatorService.Setup(x => x.ConvertToMonthly(500, "Q")).Returns(1);
            RegularPayment quarterly = _helper.MapRegularPayment(500, "Q");

            Assert.AreEqual("monthly", quarterly.Frequency);
            Assert.AreEqual(1, quarterly.Amount);

            _calculatorService.Setup(x => x.ConvertToMonthly(500, "L")).Returns(1);
            RegularPayment lastDayOfMonth = _helper.MapRegularPayment(500, "L");

            Assert.AreEqual("monthly", lastDayOfMonth.Frequency);
            Assert.AreEqual(1, lastDayOfMonth.Amount);

            _calculatorService.Setup(x => x.ConvertToMonthly(500, "A")).Returns(1);
            RegularPayment annually = _helper.MapRegularPayment(500, "A");

            Assert.AreEqual("monthly", annually.Frequency);
            Assert.AreEqual(1, annually.Amount);

            RegularPayment monthly = _helper.MapRegularPayment(123.45M, "M");

            Assert.AreEqual("monthly", monthly.Frequency);
            Assert.AreEqual(123.45M, monthly.Amount);

            RegularPayment weekly = _helper.MapRegularPayment(123.45M, "W");

            Assert.AreEqual("weekly", weekly.Frequency);
            Assert.AreEqual(123.45M, weekly.Amount);

            RegularPayment fortnightly = _helper.MapRegularPayment(123.45M, "F");

            Assert.AreEqual("fortnightly", fortnightly.Frequency);
            Assert.AreEqual(123.45M, fortnightly.Amount);

            RegularPayment fourWeekly = _helper.MapRegularPayment(123.45M, "4");

            Assert.AreEqual("4week", fourWeekly.Frequency);
            Assert.AreEqual(123.45M, fourWeekly.Amount);

            RegularPayment invalid = _helper.MapRegularPayment(123.45M, "testing...");

            Assert.AreEqual("", invalid.Frequency);
            Assert.AreEqual(123.45M, invalid.Amount);
        }
Exemple #11
0
        public void AddRegularPayment(RegularPayment regularPayment)
        {
            _logger.LogInformation("AddRegularPaymant method");
            if (regularPayment == null)
            {
                throw new EntityNullException(typeof(RegularPayment));
            }

            if (regularPayment.Payer.Equals(regularPayment.Recipient))
            {
                throw new RegularPaymentSameAccount(regularPayment.Payer);
            }

            var sameID = _repository.GetRegularPayments().FirstOrDefault(rp => rp.PaymentID == regularPayment.PaymentID);

            if (sameID != null)
            {
                throw new RegularPaymentSameId(regularPayment.PaymentID.ToString());
            }

            _repository.CreateRegularPayment(regularPayment);
        }
        // GET: RegularPayments/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            RegularPayment regularPayment = db.RegularPayments.Find(id);

            if (regularPayment == null)
            {
                return(HttpNotFound());
            }
            RegularPaymentEditModel model =
                new RegularPaymentEditModel()
            {
                RegularPaymentId = regularPayment.RegularPaymentId, Sum = regularPayment.Sum, UserName = regularPayment.RecipientUser.FullName,
                PayoutFrom       = regularPayment.PayoutFrom, PayoutTo = regularPayment.PayoutTo,
                ProjectCode      = PaymentRequestEditModel.getProjectCode(regularPayment.Project.Name),
                ProjectShortName = PaymentRequestEditModel.getProjectShortName(regularPayment.Project.Name)
            };

            return(View(model));
        }
 public void DeleteRegularPayment(RegularPayment regularPayment)
 {
     EntityWrapper.DeleteRegularPayment(regularPayment);
 }
Exemple #14
0
        public ActionResult UploadForm(RateUploadModel input)
        {
            Dictionary <string, double> stavki = new Dictionary <string, double>();

            if (ModelState.IsValid)
            {
                if (input.UploadFile != null)
                {
                    using (var package = new ExcelPackage(input.UploadFile.InputStream))
                    {
                        var Sheet   = package.Workbook.Worksheets[1];
                        int lastRow = Sheet.Dimension.End.Row;
                        int lastCol = Sheet.Dimension.End.Column;
                        int i       = 5;
                        do
                        {
                            if (Sheet.Cells[i, 1].Value != null && Sheet.Cells[i, 5].Value != null)
                            {
                                if (!String.IsNullOrEmpty(Sheet.Cells[i, 1].Value.ToString()))
                                {
                                    if (!String.IsNullOrEmpty(Sheet.Cells[i, 5].Value.ToString()))
                                    {
                                        double v;
                                        if (double.TryParse(Sheet.Cells[i, 5].Value.ToString(), out v))
                                        {
                                            stavki.Add(Sheet.Cells[i, 1].Value.ToString().Trim().Replace(". ", ".").Replace(". ", ".").ToUpper(), v);
                                        }
                                    }
                                }
                            }
                            i++;
                        } while (i <= lastRow);

                        PaymentsGroup pg = new PaymentsGroup()
                        {
                            State = PaymentsGroupState.InProcess, WhenCreated = DateTime.Now, WhenPaidOut = DateTime.Now
                        };
                        pg = db.PaymentsGroups.Add(pg);

                        foreach (KeyValuePair <string, double> s in stavki)
                        {
                            ApplicationUser user = db.Users.FirstOrDefault(x => x.ShortName.Replace(". ", ".").ToUpper() == s.Key.Replace(". ", ".").ToUpper());
                            if (user != null)
                            {
                                double limit = input.SalaryRate * s.Value / 100;
                                double c_sum = 0;
                                foreach (var b in user.UserBalances.OrderBy(x => x.Sum).ToList())
                                {
                                    if (b.Sum == 0)
                                    {
                                        continue;
                                    }
                                    UserPayment p = null;

                                    if (b.Sum > (limit - c_sum))
                                    {
                                        double rsum = PaymentRequest.TruncSum(limit - c_sum);
                                        if (((uint)rsum) == 0)
                                        {
                                            continue;
                                        }
                                        p = new UserPayment()
                                        {
                                            PaymentGroup = pg, Project = b.Project, User = user, Sum = rsum
                                        };

                                        p = db.UserPayments.Add(p);
                                        break;
                                    }
                                    else
                                    {
                                        double rsum = PaymentRequest.TruncSum(b.Sum);
                                        if (((uint)rsum) == 0)
                                        {
                                            continue;
                                        }
                                        p = new UserPayment()
                                        {
                                            PaymentGroup = pg, Project = b.Project, User = user, Sum = rsum
                                        };
                                        c_sum += p.Sum;
                                        p      = db.UserPayments.Add(p);
                                    }
                                }
                            }
                            else
                            {
                                ModelState.AddModelError("", "в БД не найден " + s.Key);
                            }
                        }

                        db.SaveChanges();

                        if (input.regularPaymentIds != null)
                        {
                            //  обработка регулярных платежей
                            for (int l = 0; l < input.regularPaymentIds.Length; l++)
                            {
                                if (input.accrueRegularPayments[l])
                                {
                                    RegularPayment rp = db.RegularPayments.Find(input.regularPaymentIds[l]);
                                    if (rp != null)
                                    {
                                        // проверяем дату
                                        DateTime d_from = rp.PayoutFrom == null ? new DateTime(DateTime.Now.Year - 10, DateTime.Now.Month, 1) :
                                                          new DateTime(rp.PayoutFrom.Value.Year, rp.PayoutFrom.Value.Month, 1);
                                        DateTime d_to = rp.PayoutTo == null ? new DateTime(DateTime.Now.Year + 10, DateTime.Now.Month, 1) :
                                                        new DateTime(rp.PayoutTo.Value.Year, rp.PayoutTo.Value.Month, 1);
                                        DateTime d_now = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1);
                                        if (d_now >= d_from && d_now <= d_to)
                                        {
                                            UserPayment p = pg.UsersPayments.FirstOrDefault(x => x.Project.ProjectId == rp.Project.ProjectId && x.User.Id == rp.RecipientUser.Id);
                                            if (p == null)
                                            {
                                                p = db.UserPayments.Add(new UserPayment {
                                                    PaymentGroup = pg, Project = rp.Project, User = rp.RecipientUser, Sum = 0
                                                });
                                            }

                                            p.Sum += rp.Sum;
                                            p.RegularPaymentSum = rp.Sum;
                                            db.SaveChanges();
                                        }
                                    }
                                }
                            }
                        }

                        return(RedirectToAction("CreateConfirm/" + pg.PaymentsGroupId));
                    }
                }
                else
                {
                    UploadFormErros.Add("Не выбран файл ставок");
                }
            }

            return(RedirectToAction("UploadForm"));
        }
 private bool CheckIncomePayment(Saldo s, RegularPayment payment)
 {
     return((from income in s.Incomes.OnHands.Trans
             where income.Category.Name == payment.Article
             select income).FirstOrDefault() != null);
 }
        //
        public static void AddRegularPayment(RegularPayment regularPayment)
        {
            ServiceATMClient client = new ServiceATMClient();

            client.AddRegularPayment(regularPayment);
        }
        public static void DeleteRegularPayment(RegularPayment regularPayment)
        {
            ServiceATMClient client = new ServiceATMClient();

            client.DeleteRegularPayment(regularPayment);
        }
 public void CreateRegularPayment(RegularPayment regularPayment)
 {
     _dbContext.Add(regularPayment);
     _dbContext.SaveChanges();
 }
        public IncomeAndExpenditure Convert(IncomeAndExpenditureApiModel source, IncomeAndExpenditure destination, ResolutionContext context)
        {
            if (source == null)
            {
                return(null);
            }
            if (destination == null)
            {
                destination = new IncomeAndExpenditure();
            }

            destination.LowellReference = source.LowellReference;
            destination.User            = source.User;
            destination.Created         = source.Created;
            destination.HasArrears      = source.HasArrears;

            destination.EmploymentStatus  = _mapperHelper.ConvertEmploymentStatusFromCaseflow(source.EmploymentStatus);
            destination.HousingStatus     = _mapperHelper.ConvertHousingStatusFromCaseflow(source.HousingStatus);
            destination.AdultsInHousehold = source.AdultsInHousehold;
            destination.Children16to18    = source.Children16to18;
            destination.ChildrenUnder16   = source.ChildrenUnder16;

            destination.IncomeTotal      = source.IncomeTotal;
            destination.ExpenditureTotal = source.ExpenditureTotal;
            destination.DisposableIncome = source.DisposableIncome;

            destination.OtherDebts = _mapper.Map <List <SaveOtherDebts> >(source.OtherDebts);

            RegularPayment salary = _mapperHelper.MapRegularPayment(source.Salary, source.SalaryFrequency);

            destination.Salary          = salary.Amount;
            destination.SalaryFrequency = salary.Frequency;

            RegularPayment pension = _mapperHelper.MapRegularPayment(source.Pension, source.PensionFrequency);

            destination.Pension          = pension.Amount;
            destination.PensionFrequency = pension.Frequency;

            RegularPayment earningsTotal = _mapperHelper.MapRegularPayment(source.EarningsTotal, source.EarningsTotalFrequency);

            destination.EarningsTotal          = earningsTotal.Amount;
            destination.EarningsTotalFrequency = earningsTotal.Frequency;

            RegularPayment benefits = _mapperHelper.MapRegularPayment(source.BenefitsTotal, source.BenefitsTotalFrequency);

            destination.BenefitsTotal          = benefits.Amount;
            destination.BenefitsTotalFrequency = benefits.Frequency;

            RegularPayment otherIncome = _mapperHelper.MapRegularPayment(source.OtherIncome, source.OtherincomeFrequency);

            destination.OtherIncome          = otherIncome.Amount;
            destination.OtherincomeFrequency = otherIncome.Frequency;

            Outgoing applianceOrFurnitureRental = _mapperHelper.MapOutgoing(source.Rental, source.RentalFrequency, source.RentalArrears);

            destination.Rental          = applianceOrFurnitureRental.Amount;
            destination.RentalArrears   = applianceOrFurnitureRental.ArrearsAmount;
            destination.RentalFrequency = applianceOrFurnitureRental.Frequency;

            Outgoing childMaintenance = _mapperHelper.MapOutgoing(source.ChildMaintenance, source.ChildMaintenanceFrequency, source.ChildMaintenanceArrears);

            destination.ChildMaintenance          = childMaintenance.Amount;
            destination.ChildMaintenanceArrears   = childMaintenance.ArrearsAmount;
            destination.ChildMaintenanceFrequency = childMaintenance.Frequency;

            Outgoing councilTax = _mapperHelper.MapOutgoing(source.CouncilTax, source.CouncilTaxFrequency, source.CouncilTaxArrears);

            destination.CouncilTax          = councilTax.Amount;
            destination.CouncilTaxArrears   = councilTax.ArrearsAmount;
            destination.CouncilTaxFrequency = councilTax.Frequency;

            Outgoing utilitiesTotal = _mapperHelper.MapOutgoing(source.UtilitiesTotal, source.UtilitiesTotalFrequency, source.UtilitiesTotalArrears);

            destination.UtilitiesTotal          = utilitiesTotal.Amount;
            destination.UtilitiesTotalArrears   = utilitiesTotal.ArrearsAmount;
            destination.UtilitiesTotalFrequency = utilitiesTotal.Frequency;

            Outgoing electricity    = new Outgoing();
            Outgoing gas            = new Outgoing();
            Outgoing otherUtilities = new Outgoing();

            if ((source.Electricity > 0.00M || source.Gas > 0.00M || source.OtherUtilities > 0.00M) && source.UtilitiesTotal >= 0.00M)
            {
                electricity                      = _mapperHelper.MapOutgoing(source.Electricity, source.ElectricityFrequency, source.ElectricityArrears);
                destination.Electricity          = electricity.Amount;
                destination.ElectricityArrears   = electricity.ArrearsAmount;
                destination.ElectricityFrequency = electricity.Frequency;

                gas                      = _mapperHelper.MapOutgoing(source.Gas, source.GasFrequency, source.GasArrears);
                destination.Gas          = gas.Amount;
                destination.GasArrears   = gas.ArrearsAmount;
                destination.GasFrequency = gas.Frequency;

                otherUtilities                      = _mapperHelper.MapOutgoing(source.OtherUtilities, source.OtherUtilitiesFrequency, source.OtherUtilitiesArrears);
                destination.OtherUtilities          = otherUtilities.Amount;
                destination.OtherUtilitiesArrears   = otherUtilities.ArrearsAmount;
                destination.OtherUtilitiesFrequency = otherUtilities.Frequency;
            }

            if ((source.Electricity == 0.00M && source.Gas == 0.00M && source.OtherUtilities == 0.00M) && source.UtilitiesTotal > 0.00M)
            {
                decimal utilities = source.UtilitiesTotal / 2;
                decimal arrears   = source.UtilitiesTotalArrears / 2;
                var     frequency = source.UtilitiesTotalFrequency;

                electricity                      = _mapperHelper.MapOutgoing(source.UtilitiesTotal / 2, source.UtilitiesTotalFrequency, source.UtilitiesTotalArrears / 2);
                destination.Electricity          = electricity.Amount;
                destination.ElectricityArrears   = electricity.ArrearsAmount;
                destination.ElectricityFrequency = electricity.Frequency;

                gas                      = _mapperHelper.MapOutgoing(source.UtilitiesTotal / 2, source.UtilitiesTotalFrequency, source.UtilitiesTotalArrears / 2);
                destination.Gas          = gas.Amount;
                destination.GasArrears   = gas.ArrearsAmount;
                destination.GasFrequency = gas.Frequency;
            }

            Outgoing mortgage = _mapperHelper.MapOutgoing(source.Mortgage, source.MortgageFrequency, source.MortgageArrears);

            destination.Mortgage          = mortgage.Amount;
            destination.MortgageArrears   = mortgage.ArrearsAmount;
            destination.MortgageFrequency = mortgage.Frequency;

            Outgoing homeContents = _mapperHelper.MapOutgoing(source.HomeContents, source.HomeContentsFrequency, source.HomeContentsArrears);

            destination.HomeContents          = homeContents.Amount;
            destination.HomeContentsArrears   = homeContents.ArrearsAmount;
            destination.HomeContentsFrequency = homeContents.Frequency;

            Outgoing rent = _mapperHelper.MapOutgoing(source.Rent, source.RentFrequency, source.RentArrears);

            destination.Rent          = rent.Amount;
            destination.RentArrears   = rent.ArrearsAmount;
            destination.RentFrequency = rent.Frequency;

            Outgoing securedLoans = _mapperHelper.MapOutgoing(source.SecuredLoans, source.SecuredLoansFrequency, source.SecuredloansArrears);

            destination.SecuredLoans          = securedLoans.Amount;
            destination.SecuredloansArrears   = securedLoans.ArrearsAmount;
            destination.SecuredLoansFrequency = securedLoans.Frequency;

            Outgoing tvLicense = _mapperHelper.MapOutgoing(source.TvLicence, source.TvLicenceFrequency, source.TvLicenceArrears);

            destination.TvLicence          = tvLicense.Amount;
            destination.TvLicenceArrears   = tvLicense.ArrearsAmount;
            destination.TvLicenceFrequency = tvLicense.Frequency;

            Outgoing water = _mapperHelper.MapOutgoing(source.Water, source.WaterFrequency, source.WaterArrears);

            destination.Water          = water.Amount;
            destination.WaterArrears   = water.ArrearsAmount;
            destination.WaterFrequency = water.Frequency;

            RegularPayment healthcare = _mapperHelper.MapRegularPayment(source.Healthcare, source.HealthcareFrequency);

            destination.Healthcare          = healthcare.Amount;
            destination.HealthcareFrequency = healthcare.Frequency;

            RegularPayment leisure = _mapperHelper.MapRegularPayment(source.Leisure, source.LeisureFrequency);

            destination.Leisure          = leisure.Amount;
            destination.LeisureFrequency = leisure.Frequency;

            RegularPayment housekeeping = _mapperHelper.MapRegularPayment(source.Housekeeping, source.HousekeepingFrequency);

            destination.Housekeeping          = housekeeping.Amount;
            destination.HousekeepingFrequency = housekeeping.Frequency;

            RegularPayment pensionInsurance = _mapperHelper.MapRegularPayment(source.PensionInsurance, source.PensionInsuranceFrequency);

            destination.PensionInsurance          = pensionInsurance.Amount;
            destination.PensionInsuranceFrequency = pensionInsurance.Frequency;

            RegularPayment personalCosts = _mapperHelper.MapRegularPayment(source.PersonalCosts, source.PersonalCostsFrequency);

            destination.PersonalCosts          = personalCosts.Amount;
            destination.PersonalCostsFrequency = personalCosts.Frequency;

            RegularPayment professionalCosts = _mapperHelper.MapRegularPayment(source.ProfessionalCosts, source.ProfessionalCostsFrequency);

            destination.ProfessionalCosts          = professionalCosts.Amount;
            destination.ProfessionalCostsFrequency = professionalCosts.Frequency;

            RegularPayment savings = _mapperHelper.MapRegularPayment(source.SavingsContributions, source.SavingsContributionsFrequency);

            destination.SavingsContributions          = savings.Amount;
            destination.SavingsContributionsFrequency = savings.Frequency;

            RegularPayment schoolCosts = _mapperHelper.MapRegularPayment(source.SchoolCosts, source.SchoolCostsFrequency);

            destination.SchoolCosts          = schoolCosts.Amount;
            destination.SchoolCostsFrequency = schoolCosts.Frequency;

            RegularPayment travel = _mapperHelper.MapRegularPayment(source.Travel, source.TravelFrequency);

            destination.Travel          = travel.Amount;
            destination.TravelFrequency = travel.Frequency;

            return(destination);
        }
        public ActionResult Create(RegularPaymentEditModel input)
        {
            if (ModelState.IsValid)
            {
                var currentUser = manager.FindById(User.Identity.GetUserId());
                input.isDublicateErr = false;

                if (input.PayoutFrom == null && input.PayoutTo == null)
                {
                    ModelState.AddModelError("", "Ошибка ввода даты");
                    return(View(input));
                }
                ApplicationUser user = db.Users.FirstOrDefault(x => x.FullName == input.UserName);
                if (user == null)
                {
                    ModelState.AddModelError("", "Не найден пользователь");
                    return(View(input));
                }
                Project project = PaymentRequestsController.ProjectFind(db, input.ProjectCode, input.ProjectShortName);
                if ((input.ProjectCode != null && input.ProjectShortName != null) || project != null)
                {
                    if (project == null)
                    {
                        Department dept = db.Departments.SingleOrDefault(x => x.Name == "_Резерв");
                        if (dept == null)
                        {
                            dept = db.Departments.Add(new Department {
                                Name = "_Резерв", Boss = currentUser
                            });
                            db.SaveChanges();
                            dept = db.Departments.SingleOrDefault(x => x.Name == "_Резерв");
                        }
                        string ProjectName = input.ProjectCode + "_" + input.ProjectShortName;
                        project = db.Projects.Add(new Project()
                        {
                            Department = dept, Name = ProjectName
                        });
                        db.SaveChanges();
                    }

                    RegularPayment rp = db.RegularPayments.FirstOrDefault(x => x.Project.ProjectId == project.ProjectId && x.RecipientUser.Id == user.Id);
                    if (rp == null)
                    {
                        db.RegularPayments.Add(
                            new RegularPayment()
                        {
                            Project       = project,
                            RecipientUser = user,
                            Sum           = input.Sum,
                            AppointedUser = currentUser,
                            PayoutFrom    = input.PayoutFrom,
                            PayoutTo      = input.PayoutTo
                        });
                        db.SaveChanges();
                        return(RedirectToAction("Index"));
                    }
                    else
                    {
                        ModelState.AddModelError("", "Регулярная выплата для " + user.FullName + " по проекту " + project.Name + " уже существует");
                        input.isDublicateErr   = true;
                        input.RegularPaymentId = rp.RegularPaymentId;
                        return(View(input));
                    }
                }
                else
                {
                    ModelState.AddModelError("", "Ошибка создания проекта");
                    return(View(input));
                }
            }

            return(View(input));
        }