public LoanPercentSetting Save([FromBody] LoanPercentSetting setting) { if (setting.Id == 0) { setting.OrganizationId = _sessionContext.OrganizationId; } ModelState.Clear(); TryValidateModel(setting); ModelState.Validate(); if (setting.Id > 0) { _repository.Update(setting); } else { _repository.Insert(setting); } return(setting); }
private string SearchParts(string text, Contract model, User user, LoanPercentSetting profile) { text = ReplacePart(text, "###номер билета&", model.ContractNumber); text = ReplacePart(text, "###дата билета&", model.ContractDate.ToString("dd.MM.yyyy")); text = ReplacePart(text, "###клиент&", model.ContractData.Client.Fullname); text = ReplacePart(text, "###РНН клиента&", model.ContractData.Client.IdentityNumber); text = ReplacePart(text, "###номер уд&", model.ContractData.Client.DocumentNumber); text = ReplacePart(text, "###выдано&", model.ContractData.Client.DocumentDate.ToString("dd.MM.yyyy")); text = ReplacePart(text, "###кем&", model.ContractData.Client.DocumentProvider); text = ReplacePart(text, "###адресс клиента&", model.ContractData.Client.Address); text = ReplacePart(text, "###название ломбарда&", _branchContext.Configuration.LegalSettings.LegalName); text = ReplacePart(text, "###оценка&", model.EstimatedCost.ToString()); text = ReplacePart(text, "###сумма оценки&", model.EstimatedCost.ToWords()); text = ReplacePart(text, "###ссуда&", model.LoanCost.ToString()); text = ReplacePart(text, "###сумма ссуды&", model.LoanCost.ToWords()); text = ReplacePart(text, "###дата возврата&", model.OriginalMaturityDate.ToString("dd.MM.yyyy")); text = ReplacePart(text, "###процент&", model.LoanPercent.ToString("n4")); text = ReplacePart(text, "###телефон ломбарда&", _branchContext.Configuration.ContactSettings.Phone); text = ReplacePart(text, "###срок займа&", model.MaturityDate.MonthDifference(model.ContractDate).ToString()); text = ReplacePart(text, "###процент год&", decimal.ToInt32(Math.Round(model.LoanPercent * 30 * 12)).ToString()); text = ReplacePart(text, "###процент месяц&", Math.Round(model.LoanPercent * 30, 1).ToString("N1")); text = ReplacePart(text, "###процент штраф&", model.PenaltyPercent.ToString("N4")); if (model.CollateralType == CollateralType.Car) { var position = model.Positions.FirstOrDefault(); if (position != null) { var car = (Car)position.Position; text = ReplacePart(text, "###марка&", car.Mark); text = ReplacePart(text, "###модель&", car.Model); text = ReplacePart(text, "###номер&", car.TransportNumber); text = ReplacePart(text, "###год выпуска&", car.ReleaseYear.ToString()); text = ReplacePart(text, "###двигатель&", car.MotorNumber); text = ReplacePart(text, "###кузов&", car.BodyNumber); text = ReplacePart(text, "###цвет&", car.Color); text = ReplacePart(text, "###номер тс&", car.TechPassportNumber); text = ReplacePart(text, "###дата тс&", (car.TechPassportDate.HasValue ? car.TechPassportDate.Value.ToString("dd.MM.yyyy") : string.Empty)); } } else if (model.CollateralType == CollateralType.Machinery) { var position = model.Positions.FirstOrDefault(); if (position != null) { var machinery = (Machinery)position.Position; text = ReplacePart(text, "###марка&", machinery.Mark); text = ReplacePart(text, "###модель&", machinery.Model); text = ReplacePart(text, "###номер&", machinery.TransportNumber); text = ReplacePart(text, "###год выпуска&", machinery.ReleaseYear.ToString()); text = ReplacePart(text, "###двигатель&", machinery.MotorNumber); text = ReplacePart(text, "###кузов&", machinery.BodyNumber); text = ReplacePart(text, "###цвет&", machinery.Color); text = ReplacePart(text, "###номер тс&", machinery.TechPassportNumber); text = ReplacePart(text, "###дата тс&", (machinery.TechPassportDate.HasValue ? machinery.TechPassportDate.Value.ToString("dd.MM.yyyy") : string.Empty)); } } text = ReplacePart(text, "###адресс ломбарда&", _branchContext.Configuration.ContactSettings.Address); text = ReplacePart(text, "###эксперт&", user.Fullname); text = ReplacePart(text, "###мораторий&", ((profile?.MinLoanPeriod ?? 90) / 30).ToString()); return(text); }