public void AddPercents() { var deposits = Uow.CustomerDepositRepository.GetAll().Where(x => !x.IsPaid).Include(x => x.DepositPayments).ToList(); foreach (var customerDeposit in deposits) { var date = customerDeposit.DepositPayments.Last().DateTime; var daysInMonth = DateTime.DaysInMonth(date.Year, date.Month); var nextPayment = date.AddDays(daysInMonth); if (date == customerDeposit.EndDate) { customerDeposit.IsPaid = true; continue; } if (nextPayment.Date == GlobalValues.BankDateTime.Date) { var percentSum = _iCalculationDepositService.CalculatePercentSum(customerDeposit.Bill.Sum, customerDeposit.Deposit.InterestRate, date); customerDeposit.Bill.Sum = _iCalculationDepositService.AddPercentToMainSum(customerDeposit.Bill.Sum, percentSum); customerDeposit.DepositPayments.Add(new DepositPayment() { Currency = Currency.Blr, DateTime = GlobalValues.BankDateTime, DestinationBillId = customerDeposit.BillId, Sum = percentSum }); } } Uow.SaveChanges(); }
public void Execute(PaymentUse paymentUse) { var paymentUseRepository = Uow.GetRepository <PaymentUse>(); paymentUseRepository.Update(paymentUse); Uow.SaveChanges(); }
public void Execute(DicColorTZRequestRelation colorTz) { var repo = Uow.GetRepository <DicColorTZRequestRelation>(); repo.Create(colorTz); Uow.SaveChanges(); }
public void Update(DomainCustomerCredit domainCredit) { var credit = Mapper.Map <CustomerCredit>(domainCredit); Uow.CustomerCreditRepository.Update(credit); Uow.SaveChanges(); }
public void Execute(ApplicationUser user) { var repo = Uow.GetRepository <ApplicationUser>(); repo.Update(user); Uow.SaveChanges(); }
public void Execute(int protectionDocId, List <ProtectionDocCustomer> customers) { var protectionDocRepository = Uow.GetRepository <ProtectionDoc>(); var protectionDoc = protectionDocRepository.AsQueryable() .Include(pd => pd.Type) .FirstOrDefault(pd => pd.Id == protectionDocId); if (protectionDoc == null) { throw new DataNotFoundException(nameof(ProtectionDoc), DataNotFoundException.OperationType.Read, protectionDocId); } string roleCode; if (protectionDoc.Type.Code == DicProtectionDocTypeCodes.RequestTypeTrademarkCode || protectionDoc.Type.Code == DicProtectionDocTypeCodes.RequestTypeNameOfOriginCode || protectionDoc.Type.Code == DicProtectionDocTypeCodes.ProtectionDocTypeTrademarkCode || protectionDoc.Type.Code == DicProtectionDocTypeCodes.ProtectionDocTypeNameOfOriginCode) { roleCode = DicCustomerRoleCodes.Owner; } else { roleCode = DicCustomerRoleCodes.PatentOwner; } var roleRepository = Uow.GetRepository <DicCustomerRole>(); var owner = roleRepository.AsQueryable().FirstOrDefault(r => r.Code == roleCode); if (owner == null) { throw new DataNotFoundException(nameof(DicCustomerRole), DataNotFoundException.OperationType.Read, roleCode); } var protectionDocCustomerRepository = Uow.GetRepository <ProtectionDocCustomer>(); foreach (var customer in customers) { var customerRole = roleRepository.GetById(customer.CustomerRoleId); customer.ProtectionDocId = protectionDocId; if (customerRole.Code == DicCustomerRoleCodes.Declarant) { var patentOwner = new ProtectionDocCustomer { CustomerId = customer.CustomerId, ProtectionDocId = protectionDocId, Address = customer.Address, CustomerRoleId = owner.Id, Phone = customer.Phone, PhoneFax = customer.PhoneFax, MobilePhone = customer.MobilePhone, Email = customer.Email }; protectionDocCustomerRepository.Create(patentOwner); } } protectionDocCustomerRepository.CreateRange(customers); Uow.SaveChanges(); }
public void ExecuteAsync(ContractWorkflow contractWorkflow) { var contractWorkflowRepository = Uow.GetRepository <ContractWorkflow>(); contractWorkflowRepository.Update(contractWorkflow); Uow.SaveChanges(); }
public void Execute(RequestDocument requestDocument) { var repo = Uow.GetRepository <RequestDocument>(); repo.Create(requestDocument); Uow.SaveChanges(); }
public void Execute(ProtectionDocDocument protectionDocDocument) { var repo = Uow.GetRepository <ProtectionDocDocument>(); repo.Create(protectionDocDocument); Uow.SaveChanges(); }
public void Execute(IPCRequest ipcRequest) { var repo = Uow.GetRepository <IPCRequest>(); repo.Update(ipcRequest); Uow.SaveChanges(); }
// DELETE: api/DashboardApi/5 public HttpResponseMessage Delete(int id) { try { var entity = Uow.Forms.GetAll() .Where(f => f.Id == id) .Include(f => f.InsuranceProvider) .FirstOrDefault(); if (entity == null) { return(Request.CreateResponse(HttpStatusCode.NotFound)); } string message = entity.InsuranceProvider.Name + ":" + entity.FileName; var localFullPath = HttpContext.Current.Server.MapPath(entity.FileUrl); Uow.Forms.Delete(id); Uow.SaveChanges(); if (File.Exists(localFullPath)) { File.Delete(localFullPath); } LogDelete(message); return(Request.CreateResponse(HttpStatusCode.OK)); } catch (Exception ex) { return(Request.CreateResponse(HttpStatusCode.BadRequest)); } }
public void Execute(List <ExpertSearchSimilar> similars) { var repo = Uow.GetRepository <ExpertSearchSimilar>(); repo.DeleteRange(similars); Uow.SaveChanges(); }
public void Execute(UserClaimDto userClaimDto) { var userClaimsRepository = Uow.GetRepository <UserClaim>(); userClaimsRepository.Create(userClaimDto.ToUserClaim); Uow.SaveChanges(); }
public void Update(DomainDeposit domainDeposit) { var deposit = Mapper.Map <Deposit>(domainDeposit); Uow.DepositRepository.Update(deposit); Uow.SaveChanges(); }
public void CheckPayments() { var overdueCredits = GetOverdueCredits(); foreach (var credit in overdueCredits) { var overduePayments = GetOverduePayments(credit); var overdueMainSum = 0.0; var overduePercentSum = 0.0; foreach (var item in overduePayments) { var paidMainSum = item.CreditPayments.Sum(x => x.MainSum); var paidPercentSum = item.CreditPayments.Sum(x => x.PercentSum); var paidDelayMainSum = item.CreditPayments.Sum(x => x.DelayMainSum); var paidDelayPercentSum = item.CreditPayments.Sum(x => x.DelayPercentSum); overdueMainSum += Math.Round((item.MainSum - paidMainSum) * _fineForMainDebt); overduePercentSum += Math.Round((item.PercentSum - paidPercentSum) * _fineForPercentDebt); item.Debt = item.Debt ?? new Debt(); item.Debt.MainSum += Math.Max(overdueMainSum - paidDelayMainSum, 0); item.Debt.PercentSum += Math.Max(overduePercentSum - paidDelayPercentSum, 0); } } Uow.SaveChanges(); }
public void Execute(BoundPaymentDto boundPaymentDto) { var payment = GetPayment(boundPaymentDto.PaymentId); var paymentInvoice = GetPaymentInvoice(boundPaymentDto.PaymentInvoiceId); var currentUser = this.GetCurrentUser(); var paymentUse = new PaymentUse { Payment = payment, PaymentInvoice = paymentInvoice, Request = paymentInvoice.Request, ProtectionDoc = paymentInvoice.ProtectionDoc, Contract = paymentInvoice.Contract, Amount = boundPaymentDto.Amount, Description = boundPaymentDto.Description, DateCreate = DateTimeOffset.Now, EmployeeCheckoutPaymentName = currentUser.NameRu }; payment.PaymentUseAmmountSumm = payment.PaymentUses.Sum(x => x.Amount) + paymentUse.Amount; Uow.GetRepository <Payment>().Update(paymentUse.Payment); Uow.GetRepository <PaymentUse>().Create(paymentUse); Uow.SaveChanges(); }
public void Execute(PaymentInvoice paymentInvoice) { var paymentInvoiceRepository = Uow.GetRepository <PaymentInvoice>(); paymentInvoiceRepository.Delete(paymentInvoice); Uow.SaveChanges(); }
public HttpResponseMessage Post(InsuranceProvider model) { try { Uow.InsuranceProviders.Add(model); //// START: Add Default Rebates var policyTypeList = GetPolicyTypes(); foreach (var policyType in policyTypeList) { var defaultRebateItem = new DefaultRebate { InsuranceProviderId = model.Id, PolicyTypeId = policyType.Id, Rate = 0 }; Uow.DefaultRebates.Add(defaultRebateItem); } //// END: Add Default Rebates Uow.SaveChanges(); LogAdd(model); return(Request.CreateResponse(HttpStatusCode.OK, model)); } catch (Exception ex) { return(Request.CreateResponse(HttpStatusCode.BadRequest)); } }
public void Execute(ICISRequest icisRequest) { var repo = Uow.GetRepository <ICISRequest>(); repo.Update(icisRequest); Uow.SaveChanges(); }
public async Task <int> ExecuteAsync(ContractDetailDto contractDetailDto) { var contractRepository = Uow.GetRepository <Contract>(); var contract = await contractRepository .AsQueryable() .Include(r => r.ProtectionDocType) .Include(r => r.Type) .Include(r => r.Category) .Include(r => r.RequestsForProtectionDoc).ThenInclude(cr => cr.Request).ThenInclude(cr => cr.ProtectionDocType) .FirstOrDefaultAsync(r => r.Id == contractDetailDto.Id); if (contract == null) { throw new DataNotFoundException(nameof(Contract), DataNotFoundException.OperationType.Update, contractDetailDto.Id); } _mapper.Map(contractDetailDto, contract); _numberGenerator.GenerateGosNumber(contract); contractRepository.Update(contract); Uow.SaveChanges(); return(contract.Id); }
public ActionResult Create(ClientModel model) { try { var entity = AutoMapper.Mapper.Map <Client>(model); Uow.Clients.Add(entity); Uow.SaveChanges(); LogAdd(entity); if (string.IsNullOrEmpty(model.ReturnUrl)) { return(RedirectToAction("Index")); } else { return(Redirect(model.ReturnUrl)); } } catch (Exception ex) { LoggingSvc.LogError(ex); return(View(model)); } }
public void Execute(int contractId, List <ContractProtectionDocRelationDto> contractProtectionDocRelationDtos) { var repository = Uow.GetRepository <ContractProtectionDocRelation>(); var existRelations = repository.AsQueryable().Where(rr => rr.ContractId == contractId); var existRelationIds = existRelations.Select(rr => rr.Id); var updatedRequestRelationDtos = contractProtectionDocRelationDtos.Where(r => existRelationIds.Contains(r.Id)).ToList(); if (updatedRequestRelationDtos.Any() == false) { return; } foreach (var relation in existRelations) { var contractRelationDto = updatedRequestRelationDtos.FirstOrDefault(rr => rr.Id == relation.Id); if (contractRelationDto == null) { continue; } //todo: убрать стрингу opt.Items["ContractId"] _mapper.Map(contractRelationDto, relation, opt => opt.Items["ContractId"] = contractId); } repository.UpdateRange(existRelations); Uow.SaveChanges(); }
public HttpResponseMessage ChangeUserName([FromBody] QuizzerModel model) { try { if (HasUpdatePermission(model) == false) { return(Request.CreateResponse(HttpStatusCode.BadRequest)); } var userEntity = Uow.Users.GetById(model.Id); var user = UserManager.FindById(userEntity.LocalAuthUserId); user.UserName = model.UserName; UserManager.Update(user); userEntity.UserName = user.UserName; Uow.Users.Update(userEntity); Uow.SaveChanges(); SvcContainer.UserSvc.ResetStoredUser(); return(Request.CreateResponse(HttpStatusCode.OK)); } catch (Exception ex) { SvcContainer.LoggingSvc.Log(ex); return(Request.CreateResponse(HttpStatusCode.BadRequest)); } }
public HttpResponseMessage DeleteAttachment(int id) { try { var entity = Uow.PolicyAttachments.GetAll() .Where(p => p.Id == id) .FirstOrDefault(); if (entity == null) { return(Request.CreateResponse(HttpStatusCode.NotFound)); } var localFullPath = HttpContext.Current.Server.MapPath(entity.FileUrl); Uow.PolicyAttachments.Delete(id); Uow.SaveChanges(); if (File.Exists(localFullPath)) { File.Delete(localFullPath); } return(Request.CreateResponse(HttpStatusCode.OK)); } catch (Exception) { return(Request.CreateResponse(HttpStatusCode.BadRequest)); } }
// POST: api/ClaimApi public HttpResponseMessage Post([FromBody] ClaimModel model) { try { model.StatusId = AttributeProviderSvc.GetClaimStatusIdFromName("new"); var entity = AutoMapper.Mapper.Map <Claim>(model); Uow.Claims.Add(entity); Uow.SaveChanges(); if (string.IsNullOrEmpty(model.ReturnUrl)) { //return RedirectToAction("Index"); return(Request.CreateResponse(HttpStatusCode.OK, new { returnUrl = "Index" })); } else { return(Request.CreateResponse(HttpStatusCode.OK, new { returnUrl = model.ReturnUrl })); //return Redirect(model.ReturnUrl); } } catch { return(Request.CreateResponse(HttpStatusCode.BadRequest)); //return View(); } }
private void CreateNewPolicy(Policy entity) { Uow.Policies.Add(entity); Uow.SaveChanges(); LogAdd(entity); }
public void Execute(ApplicationRole role) { var repository = Uow.GetRepository <ApplicationRole>(); repository.Update(role); Uow.SaveChanges(); }
private void SaveModifications(Policy entity) { var rIdList = Uow.Risks.GetAll() .Where(p => p.PolicyId == entity.Id) .Select(p => p.Id) .ToList(); foreach (var item in entity.Risks) { if (item.Id == 0) { item.PolicyId = entity.Id; Uow.Risks.Add(item); } else { Uow.Risks.Update(item); rIdList.Remove(item.Id); } } foreach (var item in rIdList) { Uow.Risks.Delete(item); } Uow.Policies.Update(entity); Uow.SaveChanges(); LogEdit(entity); }
public void Execute(Payment payment) { var paymentRepository = Uow.GetRepository <Payment>(); paymentRepository.Update(payment); Uow.SaveChanges(); }
public ActionResult CancelPolicy(int?id) { try { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } var entity = Uow.Policies.GetById((int)id); if (entity == null) { return(HttpNotFound()); } entity.StatusId = AttributeProviderSvc.GetPolicyStatusIdFromName("cancelled"); Uow.Policies.Update(entity); Uow.SaveChanges(); return(RedirectToAction("Index")); } catch (Exception ex) { LoggingSvc.LogError(ex); return(RedirectToAction("Details", new { id = id })); } }