Пример #1
0
        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();
        }
Пример #2
0
        public void Execute(PaymentUse paymentUse)
        {
            var paymentUseRepository = Uow.GetRepository <PaymentUse>();

            paymentUseRepository.Update(paymentUse);
            Uow.SaveChanges();
        }
Пример #3
0
        public void Execute(DicColorTZRequestRelation colorTz)
        {
            var repo = Uow.GetRepository <DicColorTZRequestRelation>();

            repo.Create(colorTz);
            Uow.SaveChanges();
        }
Пример #4
0
        public void Update(DomainCustomerCredit domainCredit)
        {
            var credit = Mapper.Map <CustomerCredit>(domainCredit);

            Uow.CustomerCreditRepository.Update(credit);
            Uow.SaveChanges();
        }
Пример #5
0
        public void Execute(ApplicationUser user)
        {
            var repo = Uow.GetRepository <ApplicationUser>();

            repo.Update(user);
            Uow.SaveChanges();
        }
Пример #6
0
        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();
        }
Пример #8
0
        public void Execute(RequestDocument requestDocument)
        {
            var repo = Uow.GetRepository <RequestDocument>();

            repo.Create(requestDocument);
            Uow.SaveChanges();
        }
Пример #9
0
        public void Execute(ProtectionDocDocument protectionDocDocument)
        {
            var repo = Uow.GetRepository <ProtectionDocDocument>();

            repo.Create(protectionDocDocument);
            Uow.SaveChanges();
        }
Пример #10
0
        public void Execute(IPCRequest ipcRequest)
        {
            var repo = Uow.GetRepository <IPCRequest>();

            repo.Update(ipcRequest);
            Uow.SaveChanges();
        }
Пример #11
0
        // 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));
            }
        }
Пример #12
0
        public void Execute(List <ExpertSearchSimilar> similars)
        {
            var repo = Uow.GetRepository <ExpertSearchSimilar>();

            repo.DeleteRange(similars);
            Uow.SaveChanges();
        }
Пример #13
0
        public void Execute(UserClaimDto userClaimDto)
        {
            var userClaimsRepository = Uow.GetRepository <UserClaim>();

            userClaimsRepository.Create(userClaimDto.ToUserClaim);
            Uow.SaveChanges();
        }
Пример #14
0
        public void Update(DomainDeposit domainDeposit)
        {
            var deposit = Mapper.Map <Deposit>(domainDeposit);

            Uow.DepositRepository.Update(deposit);
            Uow.SaveChanges();
        }
Пример #15
0
        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();
        }
Пример #16
0
        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();
        }
Пример #18
0
        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));
            }
        }
Пример #19
0
        public void Execute(ICISRequest icisRequest)
        {
            var repo = Uow.GetRepository <ICISRequest>();

            repo.Update(icisRequest);
            Uow.SaveChanges();
        }
Пример #20
0
        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);
        }
Пример #21
0
        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();
        }
Пример #23
0
        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));
            }
        }
Пример #24
0
        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));
            }
        }
Пример #25
0
        // 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();
            }
        }
Пример #26
0
        private void CreateNewPolicy(Policy entity)
        {
            Uow.Policies.Add(entity);
            Uow.SaveChanges();

            LogAdd(entity);
        }
Пример #27
0
        public void Execute(ApplicationRole role)
        {
            var repository = Uow.GetRepository <ApplicationRole>();

            repository.Update(role);
            Uow.SaveChanges();
        }
Пример #28
0
        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);
        }
Пример #29
0
        public void Execute(Payment payment)
        {
            var paymentRepository = Uow.GetRepository <Payment>();

            paymentRepository.Update(payment);
            Uow.SaveChanges();
        }
Пример #30
0
        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 }));
            }
        }