public async Task <List <Quiz> > GetFriendQuizzes(Guid id, Guid?userId = null, bool noTracking = true)
        {
            var friends    = new List <AppUser>();
            var userMapper = new BLLMapper <DAL.App.DTO.Identity.AppUser, AppUser>();
            var quizzes    = new List <Quiz>();
            var user       = await UOW.AppUsers.GetUserWithFriendsCollections(id);

            if (user.ReceivedRequests != null)
            {
                friends.AddRange(from request in user.ReceivedRequests where request.Accepted select userMapper.Map(request.AppUser));
            }
            if (user.SentRequests != null)
            {
                friends.AddRange(from request in user.SentRequests where request.Accepted select userMapper.Map(request.Recipient));
            }

            foreach (var q in friends.Select(friend =>
                                             UOW.AppUsers.GetUserWithQuizCollections(friend.Id).Result.Quizzes !.Where(a => !a.Finished)))
            {
                quizzes.AddRange(q.Select(quiz => Mapper.Map(quiz)));
            }


            return(quizzes);
        }
示例#2
0
 public void SetUp()
 {
     EMSWebsiteMapper.Initialize();
     BLLMapper.Initialize();
     _logger = Substitute.For <ILogger>();
     _uow    = Substitute.For <IUnitOfWork>();
 }
示例#3
0
 public void SetUp()
 {
     _logger     = Substitute.For <ILogger>();
     _uow        = Substitute.For <IUnitOfWork>();
     _repository = _uow.GetGenericRepository <USER>();
     _bll        = new UserBLL(_uow, _logger);
     BLLMapper.Initialize();
 }
示例#4
0
        public CategoryDTO GetProductCategory(ProductDTO prod)
        {
            var cat = _uow.Categories.GetAll()
                      .Where(c => c.Products
                             .Any(p => p.ProductId == prod.ProductId));

            return(BLLMapper.Map <CategoryDTO>(cat));
        }
示例#5
0
 public void SetUp()
 {
     _logger     = Substitute.For <ILogger>();
     _uow        = Substitute.For <IUnitOfWork>();
     _repository = _uow.GetGenericRepository <LACK2>();
     _bll        = new LACK2BLL(_uow, _logger);
     _uow.GetGenericRepository <LACK2>().ReturnsForAnyArgs(_repository);
     BLLMapper.Initialize();
 }
示例#6
0
        public void SetUp()
        {
            _logger        = Substitute.For <ILogger>();
            _uow           = Substitute.For <IUnitOfWork>();
            _repository    = _uow.GetGenericRepository <PRODUCTION>();
            _productionBll = new ProductionBLL(_logger, _uow);

            BLLMapper.Initialize();
        }
 public void SetUp()
 {
     BLLMapper.Initialize();
     _logger     = Substitute.For <ILogger>();
     _uow        = Substitute.For <IUnitOfWork>();
     _repository = _uow.GetGenericRepository <EMAIL_TEMPLATE>();
     _workflowStateRepository = _uow.GetGenericRepository <WORKFLOW_STATE>();
     _bll = new EmailTemplateBLL(_uow, _logger);
 }
        public ProductDTO GetWithMinPrice()
        {
            var products = _uow.Products.GetAll();

            int min = products.Min(p => p.Price);

            return(products.Where(p => p.Price == min)
                   .Select(product => BLLMapper.Map <ProductDTO>(product))
                   .FirstOrDefault());
        }
        public SchedulerEmailService()
        {
            logger = new NLogLogger();
            uow    = new SqlUnitOfWork(logger);

            _repositoryQuotaMonitoringDetail = uow.GetGenericRepository <QUOTA_MONITORING_DETAIL>();
            _pbck1BLL       = new PBCK1BLL(uow, logger);
            _messageService = new MessageService(logger);
            BLLMapper.InitializePBCK1();
            BLLMapper.Initialize();
        }
        public IEnumerable <SupplierDTO> GetProductSuppliers(ProductDTO prod)
        {
            var sups = _uow.Suppliers.GetAll()
                       .Select(s => BLLMapper.Map <SupplierDTO>(s));
            List <SupplierDTO> result = new List <SupplierDTO>();

            foreach (var sup in sups)
            {
                if (sup.Products.Any(
                        p => p.ProductId == prod.ProductId))
                {
                    result.Add(sup);
                }
            }
            return(result);
        }
示例#11
0
        public IEnumerable <CategoryDTO> GetSupplierCategories(SupplierDTO sup)
        {
            IEnumerable <ProductDTO> prod = BLLMapper.Map <SupplierDTO>
                                                (_uow.Suppliers.GetById(sup.SupplierId)).Products;
            var cats = _uow.Categories.GetAll()
                       .Select(c => BLLMapper.Map <CategoryDTO>(c));

            List <CategoryDTO> res = new List <CategoryDTO>();

            foreach (var p in prod)
            {
                res.Concat(cats.Where(c => c.Products.Any(
                                          product => product.ProductId == p.ProductId)));
            }

            return(res);
        }
示例#12
0
        private void CreateCk5XmlCancel(CK5 ck5)
        {
            //create xml file status 03
            var ck5Writer = new XmlCK5DataWriter();

            BLLMapper.InitializeCK5();
            BLLMapper.Initialize();
            var outboundPath = ConfigurationManager.AppSettings["XmlOutboundPath"];
            var date         = DateTime.Now.ToString("yyyyMMdd");
            var time         = DateTime.Now.ToString("hhmmss");

            var fileName  = string.Format("CK5CAN_{0}-{1}-{2}.xml", ck5.SUBMISSION_NUMBER, date, time);
            var Ck5XmlDto = new CK5BLL(_xmlMapper.uow, new NullLogger()).GetCk5ForXmlById(ck5.CK5_ID);

            Ck5XmlDto.Ck5PathXml = Path.Combine(outboundPath, fileName);

            ck5Writer.CreateCK5Xml(Ck5XmlDto, "03");
        }
        public IEnumerable <SupplierDTO> GetCategorySuppliers(CategoryDTO cat)
        {
            IEnumerable <ProductDTO> prod = (BLLMapper.Map <CategoryDTO>
                                                 (_uow.Categories.GetById(cat.CategoryId))).Products;
            var sups = _uow.Suppliers.GetAll()
                       .Select(s => BLLMapper.Map <SupplierDTO>(s));

            List <SupplierDTO> res = new List <SupplierDTO>();

            foreach (var p in prod)
            {
                res.Concat(sups.Where(s => s.Products.Any(
                                          product => product.ProductId == p.ProductId)));
            }


            return(res);
        }
示例#14
0
        public async Task <IEnumerable <ItemType> > GetAllByRestaurantAsync(Guid restaurantId, object?userId = null, bool noTracking = true)
        {
            var dalEntities = await ServiceRepository.GetAllByRestaurantAsync(restaurantId, userId, noTracking);

            return(dalEntities.Select(e => BLLMapper.Map(e)).OrderBy(e => e.IsSpecial).ThenBy(e => e.Name));
        }
 public IEnumerable <SupplierDTO> GetAll()
 {
     return(_uow.Suppliers.GetAll()
            .Select(s => BLLMapper.Map <SupplierDTO>(s)));
 }
        public IEnumerable <ProductDTO> GetBySupplier(SupplierDTO sup)
        {
            var supplier = _uow.Suppliers.GetById(sup.SupplierId);

            return(BLLMapper.Map <SupplierDTO>(supplier).Products);
        }
 public ProductDTO GetById(int id)
 {
     return(BLLMapper.Map <ProductDTO>
                (_uow.Products.GetById(id)));
 }
        public IEnumerable <ProductDTO> GetByCategory(CategoryDTO cat)
        {
            var category = _uow.Categories.GetById(cat.CategoryId);

            return(BLLMapper.Map <CategoryDTO>(category).Products);
        }
 public IEnumerable <ProductDTO> GetAll()
 {
     return(_uow.Products.GetAll()
            .Select(product => BLLMapper.Map <ProductDTO>(product)));
 }
 public void Update(ProductDTO prod)
 {
     _uow.Products.Update(BLLMapper.Map <Product>(prod));
     _uow.Save();
 }
示例#21
0
 public IEnumerable <CategoryDTO> GetAll()
 {
     return(_uow.Categories.GetAll()
            .Select(c => BLLMapper.Map <CategoryDTO>(c)));;
 }
示例#22
0
 public void Update(CategoryDTO cat)
 {
     _uow.Categories.Update(BLLMapper.Map <Category>(cat));
     _uow.Save();
 }
 public async Task <IEnumerable <NutritionInfo> > GetAllByItemAsync(Guid itemId, object?userId = null, bool noTracking = true)
 {
     return((await ServiceRepository.GetAllAsync(userId, noTracking)).Where(n => n.ItemId.Equals(itemId))
            .Select(e => BLLMapper.Map(e)));
 }
示例#24
0
 public CategoryDTO GetById(int id)
 {
     return(BLLMapper.Map <CategoryDTO>
                (_uow.Categories.GetById(id)));
 }
 public SupplierDTO GetById(int id)
 {
     return(BLLMapper.Map <SupplierDTO>
                (_uow.Suppliers.GetById(id)));
 }
示例#26
0
        public void SetUp()
        {
            var listCitis = new City[]
            {
                new City()
                {
                    Id = 1, Name = "Киев"
                },
                new City()
                {
                    Id = 2, Name = "Черкассы"
                },
            };

            Mock <IReadOnlyRepository <City> > cityReadOnlyRepository = new Mock <IReadOnlyRepository <City> >();

            cityReadOnlyRepository.Setup(m => m.GetAll()).Returns(listCitis.AsQueryable());
            cityReadOnlyRepository.Setup(x => x.GetByIdAsync(It.IsAny <int>())).ReturnsAsync(
                (int id) =>
            {
                return(cityReadOnlyRepository.Object.GetAll().FirstOrDefault(x => x.Id == id));
            });

            Mock <IReadOnlyRepository <CityDistrict> > cityDistrictReadOnlyRepository = new Mock <IReadOnlyRepository <CityDistrict> >();
            var listCityDistrict = new List <CityDistrict>();
            var city_1           = cityReadOnlyRepository.Object.GetAll().FirstOrDefault(x => x.Name == "Киев");
            int cityDistrictId   = 1;

            if (city_1 != null)
            {
                listCityDistrict.Add(new CityDistrict()
                {
                    CityId = city_1.Id,
                    Name   = "Троещина",
                    Id     = cityDistrictId++
                });
                listCityDistrict.Add(new CityDistrict()
                {
                    CityId = city_1.Id,
                    Name   = "Шевченковский р-н",
                    Id     = cityDistrictId++
                });
                listCityDistrict.Add(new CityDistrict()
                {
                    CityId = city_1.Id,
                    Name   = "Голосеевский р-н",
                    Id     = cityDistrictId++
                });
                listCityDistrict.Add(new CityDistrict()
                {
                    CityId = city_1.Id,
                    Name   = "Днепровский р-н",
                    Id     = cityDistrictId++
                });
            }
            cityDistrictReadOnlyRepository.Setup(m => m.GetAll()).Returns(listCityDistrict.AsQueryable());
            cityDistrictReadOnlyRepository.Setup(x => x.GetByIdAsync(It.IsAny <int>())).ReturnsAsync(
                (int id) =>
            {
                return(cityDistrictReadOnlyRepository.Object.GetAll().FirstOrDefault(x => x.Id == id));
            });

            Mock <IReadOnlyRepository <Street> > streetReadOnlyRepository = new Mock <IReadOnlyRepository <Street> >();
            var listStreet = new List <Street>();

            var district_1 = cityDistrictReadOnlyRepository.Object.GetAll().FirstOrDefault(x => x.Name == "Шевченковский р-н");
            int streetId   = 1;

            if (district_1 != null)
            {
                listStreet.Add(new Street()
                {
                    CityDistrictId = district_1.Id,
                    Name           = "Чорновола ул.",
                    Id             = streetId++
                });
                listStreet.Add(new Street()
                {
                    CityDistrictId = district_1.Id,
                    Name           = "Саксаганского ул.",
                    Id             = streetId++
                });
                listStreet.Add(new Street()
                {
                    CityDistrictId = district_1.Id,
                    Name           = "Ружинская ул.",
                    Id             = streetId++
                });
                listStreet.Add(new Street()
                {
                    CityDistrictId = district_1.Id,
                    Name           = "Стеценко ул.",
                    Id             = streetId++
                });
                listStreet.Add(new Street()
                {
                    CityDistrictId = district_1.Id,
                    Name           = "Победы просп.",
                    Id             = streetId++
                });
            }

            var district_2 = cityDistrictReadOnlyRepository.Object.GetAll().FirstOrDefault(x => x.Name == "Днепровский р-н");

            if (district_2 != null)
            {
                listStreet.Add(new Street()
                {
                    CityDistrictId = district_2.Id,
                    Name           = "Жмаченко генерала ул.",
                    Id             = streetId++
                });
                listStreet.Add(new Street()
                {
                    CityDistrictId = district_2.Id,
                    Name           = "Строителей ул.",
                    Id             = streetId++
                });
                listStreet.Add(new Street()
                {
                    CityDistrictId = district_2.Id,
                    Name           = "Тампере ул.",
                    Id             = streetId++
                });
            }

            streetReadOnlyRepository.Setup(m => m.GetAll()).Returns(listStreet.AsQueryable());
            streetReadOnlyRepository.Setup(x => x.GetByIdAsync(It.IsAny <int>())).ReturnsAsync(
                (int id) =>
            {
                return(streetReadOnlyRepository.Object.GetAll().FirstOrDefault(x => x.Id == id));
            });


            Mock <IRepository <RealEstate> > realEstateRepository = new Mock <IRepository <RealEstate> >();
            var listRealEstate = new List <RealEstate>();

            var street_1     = streetReadOnlyRepository.Object.GetAll().FirstOrDefault(x => x.Name == "Чорновола ул.");
            int realEstateId = 1;

            if (street_1 != null)
            {
                listRealEstate.Add(new RealEstate()
                {
                    Building     = "33/30",
                    Appartment   = 24,
                    Floor        = 6,
                    Height       = 9,
                    Area         = 54,
                    Price        = 36.000M,
                    RoomNumber   = 2,
                    CreationDate = DateTime.Now,
                    Description  = "test",
                    IsSold       = false,
                    StreetId     = street_1.Id,
                    RealtorId    = "test",
                    Id           = realEstateId++
                });
                listRealEstate.Add(new RealEstate()
                {
                    Building     = "3",
                    Appartment   = 4,
                    Floor        = 2,
                    Height       = 19,
                    Area         = 154,
                    Price        = 56.000M,
                    RoomNumber   = 2,
                    CreationDate = DateTime.Now,
                    Description  = "test",
                    IsSold       = false,
                    StreetId     = street_1.Id,
                    RealtorId    = "test",
                    Id           = realEstateId++
                });
            }

            var street_2 = streetReadOnlyRepository.Object.GetAll().FirstOrDefault(x => x.Name == "Саксаганского ул.");

            if (street_2 != null)
            {
                listRealEstate.Add(new RealEstate()
                {
                    Building     = "33/30",
                    Appartment   = 24,
                    Floor        = 6,
                    Height       = 9,
                    Area         = 54,
                    Price        = 36.000M,
                    RoomNumber   = 2,
                    CreationDate = DateTime.Now,
                    Description  = "test",
                    IsSold       = false,
                    StreetId     = street_2.Id,
                    RealtorId    = "test",
                    Id           = realEstateId++
                });
                listRealEstate.Add(new RealEstate()
                {
                    Building     = "123",
                    Appartment   = 94,
                    Floor        = 12,
                    Height       = 19,
                    Area         = 154,
                    Price        = 516.000M,
                    RoomNumber   = 4,
                    CreationDate = DateTime.Now,
                    Description  = "test",
                    IsSold       = false,
                    StreetId     = street_2.Id,
                    RealtorId    = "test",
                    Id           = realEstateId++
                });
            }

            realEstateRepository.Setup(m => m.GetAll()).Returns(listRealEstate.AsQueryable());
            realEstateRepository.Setup(x => x.GetByIdAsync(It.IsAny <int>())).ReturnsAsync(
                (int id) =>
            {
                return(realEstateRepository.Object.GetAll().FirstOrDefault(x => x.Id == id));
            });

            var unitOfWork = new Mock <IEstateAgencyUnitOfWork>();

            unitOfWork.Setup(x => x.Cities).Returns(cityReadOnlyRepository.Object);
            unitOfWork.Setup(x => x.CityDistricts).Returns(cityDistrictReadOnlyRepository.Object);
            unitOfWork.Setup(x => x.Streets).Returns(streetReadOnlyRepository.Object);
            unitOfWork.Setup(x => x.RealEstates).Returns(realEstateRepository.Object);
            var mapperFactory = new BLLMapper();

            _realtorService = new RealtorService(unitOfWork.Object, mapperFactory, new RealeEstateSort <RealEstateForRealtorDTO>(), new RealEstatesDataMapper(unitOfWork.Object, mapperFactory), new FilterForRealtor());
        }
 public void Update(SupplierDTO sup)
 {
     _uow.Suppliers.Update(BLLMapper.Map <Supplier>(sup));
     _uow.Save();
 }
示例#28
0
        private static void Bootstrap()
        {
            //initialize mappers
            EMSWebsiteMapper.Initialize();
            BLLMapper.Initialize();

            // 1. Create a new Simple Injector container
            var container = new Container();

            // register unit of work / context by request
            // http://simpleinjector.codeplex.com/wikipage?title=ObjectLifestyleManagement#PerThread
            var webLifestyle = new WebRequestLifestyle();

            container.Register <IUnitOfWork, SqlUnitOfWork>(webLifestyle);
            container.Register <ILogger, NLogLogger>();
            container.Register <ICompanyBLL, CompanyBLL>();
            container.Register <IWorkflowBLL, WorkflowBLL>();
            container.Register <IUserBLL, UserBLL>();
            container.Register <IFormsAuthenticationService, FormsAuthenticationService>();
            container.Register <IPageBLL, PageBLL>();
            container.Register <IPBCK1BLL, PBCK1BLL>();
            container.Register <ICK4CBLL, CK4CBLL>();
            container.Register <IZaidmExPOAMapBLL, ZaidmExPOAMapBLL>();
            container.Register <IVirtualMappingPlantBLL, VirtualMappingPlantBLL>();
            container.Register <IMasterDataBLL, MasterDataBLL>();
            container.Register <IZaidmExNPPBKCBLL, ZaidmExNPPBKCBLL>();
            container.Register <IPlantBLL, PlantBLL>();
            container.Register <IZaidmExGoodTypeBLL, ZaidmExGoodTypeBLL>();
            container.Register <IBrandRegistrationBLL, BrandRegistrationBLL>();
            container.Register <ICK5BLL, CK5BLL>();
            container.Register <IZaidmExProdTypeBLL, ZaidmExProdTypeBLL>();
            container.Register <IMonthBLL, MonthBLL>();
            container.Register <IDocumentSequenceNumberBLL, DocumentSequenceNumberBLL>();
            container.Register <IHeaderFooterBLL, HeaderFooterBLL>();
            container.Register <IExGroupTypeBLL, ExGroupTypeBLL>();
            container.Register <IZaidmExKPPBCBLL, ZaidmExKPPBCBLL>();
            container.Register <IChangesHistoryBLL, ChangesHistoryBLL>();
            container.Register <IMaterialBLL, MaterialBLL>();
            container.Register <IWorkflowHistoryBLL, WorkflowHistoryBLL>();
            container.Register <IUnitOfMeasurementBLL, UnitOfMeasurementBLL>();
            container.Register <IPOASKBLL, POASKBLL>();
            container.Register <IPOABLL, POABLL>();
            container.Register <IWorkflowSettingBLL, WorkflowSettingBLL>();
            container.Register <IEmailTemplateBLL, EmailTemplateBLL>();

            container.Register <IPbck1DecreeDocBLL, Pbck1DecreeDocBLL>();
            container.Register <IPbck1ProdPlanBLL, Pbck1ProdPlanBLL>();
            container.Register <ILACK1BLL, LACK1BLL>();
            container.Register <ILACK2BLL, LACK2BLL>();
            container.Register <IPrintHistoryBLL, PrintHistoryBLL>();
            container.Register <IUserAuthorizationBLL, UserAuthorizationBLL>();
            container.Register <IPOAMapBLL, POAMapBLL>();
            container.Register <ILFA1BLL, LFA1BLL>();
            container.Register <IT001KBLL, T001KBLL>();
            container.Register <IUserPlantMapBLL, UserPlantMapBLL>();
            container.Register <ICountryBLL, CountryBLL>();
            container.Register <ISupplierPortBLL, SupplierPortBLL>();
            container.Register <IPBCK7And3BLL, PBCK7AndPBCK3BLL>();
            container.Register <IBACK1BLL, BACK1BLL>();
            container.Register <IProductionBLL, ProductionBLL>();
            container.Register <IPBCK4BLL, PBCK4BLL>();
            container.Register <ICK1BLL, CK1BLL>();
            container.Register <IWasteBLL, WasteBLL>();
            container.Register <IBlockStockBLL, BlockStockBLL>();
            container.Register <IWasteRoleBLL, WasteRoleBLL>();
            container.Register <IWasteStockBLL, WasteStockBLL>();
            container.Register <INlogBLL, NlogBLL>();
            container.Register <IXmlFileLogBLL, XmlFileLogBLL>();
            container.Register <IPoaDelegationBLL, PoaDelegationBLL>();
            container.Register <IReversalBLL, ReversalBLL>();
            container.Register <ISchedulerSettingBLL, SchedulerSettingBLL>();
            container.Register <IMonthClosingBLL, MonthClosingBLL>();
            container.Register <IMonthClosingDocBLL, MonthClosingDocBLL>();
            container.Register <IMasterDataApprovalSettingBLL, MasterDataApprovalSettingBLL>();
            container.Register <IMasterDataAprovalBLL, MasterDataApprovalBLL>();
            container.Register <ILACK10BLL, LACK10BLL>();

            // 3. Optionally verify the container's configuration.
            container.Verify();

            // 4. Store the container for use by Page classes.
            _container = container;
        }
示例#29
0
 public void SetUp()
 {
     BLLMapper.Initialize();
 }