Пример #1
0
        protected override void RemoveAbstract(TeamDeleteModel entity)
        {
            var output = new LogicResult <TeamViewModel>();
            var data   = Uow.GetRepository <Team>().GetById(entity.Id);

            if (data != null)
            {
                while (data.Users.Count() > 0)
                {
                    data.Users.FirstOrDefault().TeamId = null;
                    Uow.GetRepository <User>().Update(data.Users.FirstOrDefault());
                }

                Uow.GetRepository <Team>().Remove(data);
            }
            else
            {
                output.ErrorList.Add(new Error
                {
                    Code = "400",
                    Text = "id is incorrect",
                    Type = Utils.Enums.OperationResultCode.Information
                });
            }
            Result = output;
        }
Пример #2
0
        public void Execute(DicColorTZRequestRelation colorTz)
        {
            var repo = Uow.GetRepository <DicColorTZRequestRelation>();

            repo.Create(colorTz);
            Uow.SaveChanges();
        }
Пример #3
0
        public void Execute(Payment payment)
        {
            var paymentRepository = Uow.GetRepository <Payment>();

            paymentRepository.Update(payment);
            Uow.SaveChanges();
        }
Пример #4
0
        public async Task ExecuteAsync(List <RequestEarlyReg> earlyRegs)
        {
            var earlyRegRepo = Uow.GetRepository <RequestEarlyReg>();

            earlyRegRepo.DeleteRange(earlyRegs);
            await Uow.SaveChangesAsync();
        }
Пример #5
0
        public void Execute(ApplicationRole role)
        {
            var repository = Uow.GetRepository <ApplicationRole>();

            repository.Update(role);
            Uow.SaveChanges();
        }
        public async Task <HttpResponseMessage> Delete(int userId, int personId)
        {
            await Uow.GetRepository <IUserAccountRepository>().DeleteAsync(userId, personId);

            Uow.Commit();
            return(new HttpResponseMessage(HttpStatusCode.NoContent));
        }
Пример #7
0
        public Domain.Entities.Dictionaries.DicDepartment Execute(string code)
        {
            var repo       = Uow.GetRepository <Domain.Entities.Dictionaries.DicDepartment>();
            var department = repo.AsQueryable().FirstOrDefault(d => d.Code.Equals(code));

            return(department);
        }
        public void ExecuteAsync(ContractWorkflow contractWorkflow)
        {
            var contractWorkflowRepository = Uow.GetRepository <ContractWorkflow>();

            contractWorkflowRepository.Update(contractWorkflow);
            Uow.SaveChanges();
        }
Пример #9
0
        public async Task <ProtectionDocParallelWorkflow> ExecuteAsync(int protectionDocWorkflowId)
        {
            var requestParallelWorkflowRepository = Uow.GetRepository <ProtectionDocParallelWorkflow>();
            var parallelWorkflows = requestParallelWorkflowRepository.AsQueryable();

            return(await parallelWorkflows.FirstOrDefaultAsync(x => x.ProtectionDocWorkflowId == protectionDocWorkflowId && !x.IsFinished));
        }
Пример #10
0
        public void Uow_GetList_WhereHitsLessThan7SelectPosts()
        {
            var result = Uow.GetRepository <Blog>().GetList(predicate: x => x.Hits < 7, selector: y => y.Posts);

            Assert.That(result.Count, Is.GreaterThan(0));
            Assert.That(result.FirstOrDefault().FirstOrDefault(), Is.TypeOf <Post>());
        }
Пример #11
0
        public void Execute(ICISRequest icisRequest)
        {
            var repo = Uow.GetRepository <ICISRequest>();

            repo.Update(icisRequest);
            Uow.SaveChanges();
        }
Пример #12
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 async Task <BibliographicDataDto> ExecuteAsync(int protectionDocId)
        {
            var requestRepository = Uow.GetRepository <ProtectionDoc>();

            var protectionDoc = await requestRepository
                                .AsQueryable()
                                .Include(r => r.ProtectionDocInfo).ThenInclude(i => i.BreedCountry)
                                .Include(r => r.CurrentWorkflow).ThenInclude(cw => cw.CurrentStage)
                                .Include(r => r.CurrentWorkflow).ThenInclude(cw => cw.FromStage)
                                .Include(r => r.Type)
                                .Include(r => r.ProtectionDocCustomers).ThenInclude(c => c.CustomerRole)
                                .Include(r => r.ProtectionDocCustomers).ThenInclude(c => c.Customer).ThenInclude(c => c.Type)
                                .Include(r => r.ProtectionDocCustomers).ThenInclude(c => c.Customer).ThenInclude(c => c.Country)
                                .Include(r => r.IcgsProtectionDocs).ThenInclude(i => i.Icgs)
                                .Include(r => r.IcisProtectionDocs)
                                .Include(r => r.IpcProtectionDocs)
                                .Include(r => r.ColorTzs)
                                .Include(r => r.PaymentInvoices).ThenInclude(pi => pi.Tariff)
                                .Include(r => r.PaymentInvoices).ThenInclude(pi => pi.PaymentUses)
                                .Include(r => r.PaymentInvoices).ThenInclude(pi => pi.Status)
                                .Include(r => r.EarlyRegs).ThenInclude(c => c.RegCountry)
                                .Include(r => r.Icfems)
                                .Include(r => r.SubType)
                                .Include(r => r.ProtectionDocConventionInfos)
                                .Include(r => r.Workflows).ThenInclude(w => w.CurrentStage)
                                .Include(r => r.Workflows).ThenInclude(w => w.CurrentUser)
                                .Include(r => r.Documents).ThenInclude(rd => rd.Document).ThenInclude(d => d.Type)
                                .Include(r => r.SelectionAchieveType)
                                .Include(pd => pd.Bulletins).ThenInclude(pb => pb.Bulletin)
                                .FirstOrDefaultAsync(doc => doc.Id == protectionDocId);

            return(_mapper.Map <ProtectionDoc, BibliographicDataDto>(protectionDoc));
        }
        public async Task <Request> ExecuteAsync(int protectionDocTypeId, string requestNum)
        {
            var repository = Uow.GetRepository <Request>();

            var result = repository.AsQueryable()
                         .Include(r => r.RequestInfo).ThenInclude(i => i.BreedCountry)
                         .Include(r => r.CurrentWorkflow).ThenInclude(cw => cw.CurrentStage)
                         .Include(r => r.CurrentWorkflow).ThenInclude(cw => cw.FromStage)
                         .Include(r => r.ProtectionDocType)
                         .Include(r => r.RequestCustomers).ThenInclude(c => c.CustomerRole)
                         .Include(r => r.RequestCustomers).ThenInclude(c => c.Customer).ThenInclude(c => c.Type)
                         .Include(r => r.RequestCustomers).ThenInclude(c => c.Customer).ThenInclude(c => c.Country)
                         .Include(r => r.Addressee)
                         .Include(r => r.ICGSRequests).ThenInclude(i => i.Icgs)
                         .Include(r => r.ICISRequests)
                         .Include(r => r.IPCRequests)
                         .Include(r => r.ColorTzs)
                         .Include(r => r.PaymentInvoices).ThenInclude(pi => pi.Tariff)
                         .Include(r => r.PaymentInvoices).ThenInclude(pi => pi.PaymentUses)
                         .Include(r => r.PaymentInvoices).ThenInclude(pi => pi.Status)
                         .Include(r => r.EarlyRegs).ThenInclude(c => c.RegCountry)
                         .Include(r => r.Icfems)
                         .Include(r => r.RequestType)
                         .Include(r => r.RequestConventionInfos)
                         .Include(r => r.Department)
                         .FirstOrDefaultAsync(r =>
                                              r.ProtectionDocTypeId.Equals(protectionDocTypeId) && r.RequestNum.Equals(requestNum));

            return(await result);
        }
Пример #15
0
        public DicCustomer Execute(int customerId)
        {
            var customerRepository = Uow.GetRepository <DicCustomer>();
            var customer           = customerRepository.GetById(customerId);

            return(customer);
        }
Пример #16
0
        public DicCustomerRole Execute(string code)
        {
            var repo = Uow.GetRepository <DicCustomerRole>();

            return(repo.AsQueryable()
                   .FirstOrDefault(r => r.Code == code));
        }
Пример #17
0
        public void Execute(ApplicationUser user)
        {
            var repo = Uow.GetRepository <ApplicationUser>();

            repo.Update(user);
            Uow.SaveChanges();
        }
        public DicPaymentStatus Execute(string code)
        {
            var repo = Uow.GetRepository <DicPaymentStatus>();

            return(repo.AsQueryable()
                   .FirstOrDefault(r => r.Code == code));
        }
Пример #19
0
        public DicTariff Execute(string code)
        {
            var repo = Uow.GetRepository <DicTariff>();

            return(repo.AsQueryable()
                   .FirstOrDefault(d => d.Code == code));
        }
        public async Task ExecuteAsync(ProtectionDocCustomer protectionDocCustomer)
        {
            var repo = Uow.GetRepository <ProtectionDocCustomer>();

            repo.Update(protectionDocCustomer);
            await Uow.SaveChangesAsync();
        }
Пример #21
0
        public void Execute(List <DicTariff> dicTariffs)
        {
            var dicDouteStageRepository = Uow.GetRepository <DicTariff>();

            dicDouteStageRepository?.CreateRangeAsync(dicTariffs);
            Uow.SaveChangesAsync();
        }
Пример #22
0
        public Domain.Entities.Dictionaries.DicEventType Execute(string code)
        {
            var repo = Uow.GetRepository <Domain.Entities.Dictionaries.DicEventType>();
            var type = repo.AsQueryable().FirstOrDefault(t => t.Code == code);

            return(type);
        }
Пример #23
0
        public void Execute(PaymentUse paymentUse)
        {
            var paymentUseRepository = Uow.GetRepository <PaymentUse>();

            paymentUseRepository.Update(paymentUse);
            Uow.SaveChanges();
        }
Пример #24
0
        public async Task <RequestWorkflow> ExecuteAsync(Request request, int userId)
        {
            var dicProtectionDocTypesRepository = Uow.GetRepository <DicProtectionDocType>();
            var protectionDocType = await dicProtectionDocTypesRepository.AsQueryable().FirstOrDefaultAsync(t => t.Id == request.ProtectionDocTypeId);

            var dicRouteStagesRepository = Uow.GetRepository <DicRouteStage>();
            var initialStage             = await dicRouteStagesRepository.AsQueryable().FirstOrDefaultAsync(s => !s.IsDeleted && s.IsFirst && s.RouteId == protectionDocType.RouteId);

            if (initialStage == null)
            {
                return(null);
            }

            var requestWorkflow = new RequestWorkflow
            {
                CurrentUserId  = userId,
                OwnerId        = request.Id,
                CurrentStageId = initialStage.Id,
                RouteId        = initialStage.RouteId,
                IsComplete     = initialStage.IsLast,
                IsSystem       = initialStage.IsSystem,
                IsMain         = initialStage.IsMain,
            };

            return(requestWorkflow);
        }
 public void UpdateCache <TDbEntity>(List <TDbEntity> entities)
 {
     try
     {
         CacheEntity type        = CacheEntityMap.GetEntityTypeForDBEntity <TDbEntity>();
         CacheStatus cacheStatus = Uow.CacheStatusesRepository.GetCacheStatus(type);
         cacheStatus.Status      = CacheEntryStatus.UpdateInProgress;
         cacheStatus.LastUpdated = DateTime.UtcNow;
         // try to get DB lock;
         if (Uow.CacheStatusesRepository.TryUpdate(cacheStatus))
         {
             ICachedEntitiesRepository <TDbEntity> entityRepository = Uow.GetRepository <ICachedEntitiesRepository <TDbEntity> >();
             Task task = entityRepository.UpdateCacheAsync(entities);
             task.ContinueWith(task1 =>
             {
                 using (IOptionsPlayUow uow = ObjectFactory.GetInstance <IOptionsPlayUow>())
                 {
                     cacheStatus             = uow.CacheStatusesRepository.GetCacheStatus(type);
                     cacheStatus.Status      = CacheEntryStatus.Active;
                     cacheStatus.LastUpdated = DateTime.UtcNow;
                     uow.CacheStatusesRepository.Update(cacheStatus);
                     uow.Commit();
                 }
             });
         }
     }
     catch (Exception ex)
     {
         Logging.Logger.Debug("thread ID:" + System.Threading.Thread.CurrentThread.ManagedThreadId.ToString() + ", UpdateCache Exception is:" + ex.StackTrace.ToString() + ", class is DatabaseCacheService");
     }
 }
Пример #26
0
        public async Task ExecuteAsync(List <ICGSRequest> icgsRequests)
        {
            var icgsRequestRepo = Uow.GetRepository <ICGSRequest>();

            icgsRequestRepo.DeleteRange(icgsRequests);
            await Uow.SaveChangesAsync();
        }
        public bool Execute(Guid userId)
        {
            var userRepository = Uow.GetRepository <User>();
            var user           = userRepository.GetById(userId);

            return(user != null && user.IsActive);
        }
Пример #28
0
        public Contract Execute(int requestId)
        {
            var repository = Uow.GetRepository <Contract>();

            return(repository.AsQueryable()
                   .Include(r => r.CurrentWorkflow).ThenInclude(r => r.CurrentStage)
                   .Include(r => r.CurrentWorkflow).ThenInclude(r => r.Route)
                   .Select(d => new Contract
            {
                CurrentWorkflow = new ContractWorkflow
                {
                    Route = d.CurrentWorkflow.Route,
                    CurrentStage = d.CurrentWorkflow.CurrentStage,
                    DateCreate = d.CurrentWorkflow.DateCreate,
                    Id = d.CurrentWorkflow.Id,
                    ExternalId = d.CurrentWorkflow.ExternalId,
                    DateUpdate = d.CurrentWorkflow.DateUpdate,
                    ControlDate = d.CurrentWorkflow.ControlDate,
                    CurrentStageId = d.CurrentWorkflow.CurrentStageId,
                    CurrentUserId = d.CurrentWorkflow.CurrentUserId,
                    DateReceived = d.CurrentWorkflow.DateReceived,
                    Description = d.CurrentWorkflow.Description,
                    FromStageId = d.CurrentWorkflow.FromStageId,
                    FromUserId = d.CurrentWorkflow.FromUserId,
                    OwnerId = d.CurrentWorkflow.OwnerId,
                    PreviousWorkflowId = d.CurrentWorkflow.PreviousWorkflowId,
                    RouteId = d.CurrentWorkflow.RouteId,
                    IsComplete = d.CurrentWorkflow.IsComplete,
                    IsMain = d.CurrentWorkflow.IsMain,
                    IsSystem = d.CurrentWorkflow.IsSystem
                },
                Id = d.Id
            })
                   .FirstOrDefault(r => r.Id == requestId));
        }
        public async Task ExecuteAsync(List <RequestConventionInfo> requestConventionInfos)
        {
            var requestConventionInfoRepo = Uow.GetRepository <RequestConventionInfo>();

            requestConventionInfoRepo.DeleteRange(requestConventionInfos);
            await Uow.SaveChangesAsync();
        }
        public void Execute(PaymentInvoice paymentInvoice)
        {
            var paymentInvoiceRepository = Uow.GetRepository <PaymentInvoice>();

            paymentInvoiceRepository.Delete(paymentInvoice);
            Uow.SaveChanges();
        }