Пример #1
0
        public static object GetByFilter(SessionInfo sessioninfo, string label, int jtStartIndex, int jtPageSize, string jtSorting)
        {
            try
            {
                CountryBusiness _countryBusiness = new CountryBusiness();
                //Get data from database
                List <MA_COUNTRY> countries = _countryBusiness.GetByFilter(sessioninfo, label, jtSorting);

                //Return result to jTable
                return(new
                {
                    Result = "OK",
                    Records = jtPageSize > 0 ? countries.Skip(jtStartIndex).Take(jtPageSize).ToList() : countries,
                    TotalRecordCount = countries.Count
                });
            }
            catch (BusinessWorkflowsException bex)
            {
                return(new { Result = "ERROR", Message = bex.Message });
            }
            catch (Exception ex)
            {
                return(new { Result = "ERROR", Message = ex.Message });
            }
        }
Пример #2
0
        public void Update_SuccessfullyUpdatesCountry()
        {
            // Arrange
            var countries = new List <Country>
            {
                new Country {
                    Name = "TestCountry1", Id = 1
                },
                new Country {
                    Name = "TestCountry2", Id = 2
                }
            }.AsQueryable();

            var countrymockDbSet = new Mock <DbSet <Country> >();

            countrymockDbSet.As <IQueryable <Country> >().Setup(m => m.Provider).Returns(countries.Provider);
            countrymockDbSet.As <IQueryable <Country> >().Setup(m => m.Expression).Returns(countries.Expression);
            countrymockDbSet.As <IQueryable <Country> >().Setup(m => m.ElementType).Returns(countries.ElementType);
            countrymockDbSet.As <IQueryable <Country> >().Setup(m => m.GetEnumerator()).Returns(countries.GetEnumerator());

            var mockContext = new Mock <EazyCartContext>();

            mockContext.Setup(c => c.Countries).Returns(countrymockDbSet.Object);

            var countryBusiness = new CountryBusiness(mockContext.Object);

            // Act
            countryBusiness.Update("UpdatedCountry", 1);

            // Assert
            mockContext.Verify(m => m.SaveChanges(), Times.Once());
        }
Пример #3
0
        public void AddCountry_SuccessfullyAddsACountry_WhenAllValuesAreCorrect()
        {
            // Arrange
            var countries = new List <Country>().AsQueryable();

            var countryMockDbSet = new Mock <DbSet <Country> >();

            countryMockDbSet.As <IQueryable <Country> >().Setup(m => m.Provider).Returns(countries.Provider);
            countryMockDbSet.As <IQueryable <Country> >().Setup(m => m.Expression).Returns(countries.Expression);
            countryMockDbSet.As <IQueryable <Country> >().Setup(m => m.ElementType).Returns(countries.ElementType);
            countryMockDbSet.As <IQueryable <Country> >().Setup(m => m.GetEnumerator()).Returns(countries.GetEnumerator());

            var mockContext = new Mock <EazyCartContext>();

            mockContext.Setup(m => m.Countries).Returns(countryMockDbSet.Object);

            var countryBusiness = new CountryBusiness(mockContext.Object);

            // Act
            countryBusiness.Add("TestCountry", 1);

            // Assert
            countryMockDbSet.Verify(m => m.Add(It.IsAny <Country>()), Times.Once());
            mockContext.Verify(m => m.SaveChanges(), Times.Once());
        }
Пример #4
0
        public static object GetTempLimitByFilter(SessionInfo sessioninfo, string strCountry, string strEffDateFrom, string strEffDateTo
                                                  , string strExpDateFrom, string strExpDateTo, int jtStartIndex, int jtPageSize, string jtSorting)
        {
            try
            {
                CountryBusiness _countryBusiness = new CountryBusiness();
                //Get data from database
                List <MA_COUNTRY_LIMIT> limits = _countryBusiness.GetTempLimitByFilter(sessioninfo, strCountry, strEffDateFrom, strEffDateTo
                                                                                       , strExpDateFrom, strExpDateTo, jtSorting);

                //Return result to jTable
                return(new
                {
                    Result = "OK",
                    Records = jtPageSize > 0 ? limits.Skip(jtStartIndex).Take(jtPageSize).ToList() : limits,
                    TotalRecordCount = limits.Count
                });
            }
            catch (BusinessWorkflowsException bex)
            {
                return(new { Result = "ERROR", Message = bex.Message });
            }
            catch (Exception ex)
            {
                return(new { Result = "ERROR", Message = ex.Message });
            }
        }
Пример #5
0
        public static object UpdateCountryLimit(SessionInfo sessioninfo, MA_COUNTRY_LIMIT record)
        {
            try
            {
                CountryBusiness _countryBusiness = new CountryBusiness();

                if (!record.FLAG_CONTROL)
                {
                    record.AMOUNT         = 0;
                    record.EFFECTIVE_DATE = sessioninfo.Process.CurrentDate;
                    record.EXPIRY_DATE    = sessioninfo.Process.CurrentDate;
                }

                record.LOG.MODIFYBYUSERID = sessioninfo.CurrentUserId;
                record.LOG.MODIFYDATE     = DateTime.Now;

                var updateRecord = _countryBusiness.UpdateCountryLimit(sessioninfo, record);

                return(new { Result = "OK", Record = updateRecord });
            }
            catch (Exception ex)
            {
                return(new { Result = "ERROR", Message = ex.Message });
            }
        }
Пример #6
0
        public void GetAll_ReturnsAnEmptyList_WhenThereAreNoCountries()
        {
            // Arrange
            var countries = new List <Country>().AsQueryable();

            var countryMockDbSet = new Mock <DbSet <Country> >();

            countryMockDbSet.As <IQueryable <Country> >().Setup(m => m.Provider).Returns(countries.Provider);
            countryMockDbSet.As <IQueryable <Country> >().Setup(m => m.Expression).Returns(countries.Expression);
            countryMockDbSet.As <IQueryable <Country> >().Setup(m => m.ElementType).Returns(countries.ElementType);
            countryMockDbSet.As <IQueryable <Country> >().Setup(m => m.GetEnumerator()).Returns(countries.GetEnumerator());

            var mockContext = new Mock <EazyCartContext>();

            mockContext.Setup(c => c.Countries).Returns(countryMockDbSet.Object);

            var countryBusiness = new CountryBusiness(mockContext.Object);

            // Act
            var allCountries = countryBusiness.GetAll();

            // Assert
            int expectedCount = 0;

            Assert.AreEqual(expectedCount, allCountries.Count, "List of all countries is not empty");
        }
Пример #7
0
        public AllResponseCountry All()
        {
            var response        = new AllResponseCountry();
            var countryBussines = new CountryBusiness();

            response.Result = countryBussines.ALL();
            return(response);
        }
Пример #8
0
        // The following methods are responsible for updating information when it is changed.
        /// <summary>
        /// Updates the user control every time it is loaded.
        /// </summary>
        public void UpdateUserControl()
        {
            var eazyCartContext = new EazyCartContext();

            this.cityBusiness     = new CityBusiness(eazyCartContext);
            this.countryBusiness  = new CountryBusiness(eazyCartContext);
            this.categoryBusiness = new CategoryBusiness(eazyCartContext);
            this.supplierBusiness = new SupplierBusiness(eazyCartContext);
            this.ClearAndUpdateCategoryTab();
            this.ClearAndUpdateCountryTab();
            this.ClearAndUpdateCityTab();
            this.ClearAndUpdateSupplierTab();
        }
Пример #9
0
        // The following methods are responsible for updating information when it is changed.
        /// <summary>
        /// Updates the user control every time it is loaded.
        /// </summary>
        public void UpdateUserControl()
        {
            var eazyCartContext = new EazyCartContext();

            this.productBusiness  = new ProductBusiness(eazyCartContext);
            this.categoryBusiness = new CategoryBusiness(eazyCartContext);
            this.supplierBusiness = new SupplierBusiness(eazyCartContext);
            this.unitBusiness     = new UnitBusiness(eazyCartContext);
            this.countryBusiness  = new CountryBusiness(eazyCartContext);
            this.cityBusiness     = new CityBusiness(eazyCartContext);
            this.ClearAndUpdateProductTab();
            this.ClearAndUpdateDeliveryTab();
        }
Пример #10
0
        public void Delete_ThrowsArgumentException_WhenCitiesAreRelatedToCountry()
        {
            // Arrange
            var countries = new List <Country>
            {
                new Country {
                    Name = "TestCountry1", Id = 1
                },
            }.AsQueryable();

            var cities = new List <City>
            {
                new City {
                    Name = "TestCity", Id = 1, CountryId = 1
                }
            }.AsQueryable();

            var countryMockDbSet = new Mock <DbSet <Country> >();

            countryMockDbSet.As <IQueryable <Country> >().Setup(m => m.Provider).Returns(countries.Provider);
            countryMockDbSet.As <IQueryable <Country> >().Setup(m => m.Expression).Returns(countries.Expression);
            countryMockDbSet.As <IQueryable <Country> >().Setup(m => m.ElementType).Returns(countries.ElementType);
            countryMockDbSet.As <IQueryable <Country> >().Setup(m => m.GetEnumerator()).Returns(countries.GetEnumerator());

            var cityMockDbSet = new Mock <DbSet <City> >();

            cityMockDbSet.As <IQueryable <City> >().Setup(m => m.Provider).Returns(cities.Provider);
            cityMockDbSet.As <IQueryable <City> >().Setup(m => m.Expression).Returns(cities.Expression);
            cityMockDbSet.As <IQueryable <City> >().Setup(m => m.ElementType).Returns(cities.ElementType);
            cityMockDbSet.As <IQueryable <City> >().Setup(m => m.GetEnumerator()).Returns(cities.GetEnumerator());

            var mockContext = new Mock <EazyCartContext>();

            mockContext.Setup(c => c.Countries).Returns(countryMockDbSet.Object);
            mockContext.Setup(c => c.Cities).Returns(cityMockDbSet.Object);

            var countryBusiness = new CountryBusiness(mockContext.Object);

            // Act
            try
            {
                int idToDelete = 1;
                countryBusiness.Delete(idToDelete);
                Assert.Fail("No exception was thrown.");
            }
            catch (ArgumentException exc)
            {
                string expectedMessage = "One or more cities are related to this country.";
                Assert.AreEqual(expectedMessage, exc.Message, "Another exception was thrown.");
            }
        }
Пример #11
0
 public ServicesLocalizationController(UserManager <ApplicationUser> userManager,
                                       IHttpContextAccessor httpContextAccessor,
                                       MardisContext mardisContext,
                                       ILogger <ServicesLocalizationController> logger,
                                       ILogger <ServicesFilterController> loggeFilter,
                                       IMemoryCache memoryCache) :
     base(userManager, httpContextAccessor, mardisContext, logger)
 {
     countryBusiness  = new CountryBusiness(mardisContext, memoryCache);
     provinceBusiness = new ProvinceBusiness(mardisContext, memoryCache);
     districtBusiness = new DistrictBusiness(mardisContext);
     parishBusiness   = new ParishBusiness(mardisContext);
     sectorBusiness   = new SectorBusiness(mardisContext);
 }
Пример #12
0
        public void Delete_DeletesCountriesSuccessfully_WhenNoCitiesAreRelatedToCountry()
        {
            // Arrange
            var countries = new List <Country>
            {
                new Country {
                    Name = "TestCountry1", Id = 1
                },
                new Country {
                    Name = "TestCountry2", Id = 2
                },
            }.AsQueryable();

            var cities = new List <City>
            {
                new City {
                    Name = "TestCity", Id = 1, CountryId = 1
                }
            }.AsQueryable();

            var countryMockDbSet = new Mock <DbSet <Country> >();

            countryMockDbSet.As <IQueryable <Country> >().Setup(m => m.Provider).Returns(countries.Provider);
            countryMockDbSet.As <IQueryable <Country> >().Setup(m => m.Expression).Returns(countries.Expression);
            countryMockDbSet.As <IQueryable <Country> >().Setup(m => m.ElementType).Returns(countries.ElementType);
            countryMockDbSet.As <IQueryable <Country> >().Setup(m => m.GetEnumerator()).Returns(countries.GetEnumerator());

            var cityMockDbSet = new Mock <DbSet <City> >();

            cityMockDbSet.As <IQueryable <City> >().Setup(m => m.Provider).Returns(cities.Provider);
            cityMockDbSet.As <IQueryable <City> >().Setup(m => m.Expression).Returns(cities.Expression);
            cityMockDbSet.As <IQueryable <City> >().Setup(m => m.ElementType).Returns(cities.ElementType);
            cityMockDbSet.As <IQueryable <City> >().Setup(m => m.GetEnumerator()).Returns(cities.GetEnumerator());

            var mockContext = new Mock <EazyCartContext>();

            mockContext.Setup(c => c.Countries).Returns(countryMockDbSet.Object);
            mockContext.Setup(c => c.Cities).Returns(cityMockDbSet.Object);

            var countryBusiness = new CountryBusiness(mockContext.Object);

            // Act
            int idToDelete = 2;

            countryBusiness.Delete(idToDelete);

            // Assert
            countryMockDbSet.Verify(x => x.Remove(It.IsAny <Country>()), Times.Once);
            mockContext.Verify(x => x.SaveChanges(), Times.Once);
        }
Пример #13
0
        public static object Update(SessionInfo sessioninfo, MA_COUNTRY record)
        {
            try
            {
                CountryBusiness _countryBusiness = new CountryBusiness();
                record.LABEL       = record.LABEL.ToUpper();
                record.DESCRIPTION = record.DESCRIPTION.ToUpper();

                var updateRecord = _countryBusiness.Update(sessioninfo, record);

                return(new { Result = "OK", Record = updateRecord });
            }
            catch (Exception ex)
            {
                return(new { Result = "ERROR", Message = ex.Message });
            }
        }
Пример #14
0
        public static object UpdateTempLimit(SessionInfo sessioninfo, MA_COUNTRY_LIMIT record)
        {
            try
            {
                CountryBusiness _countryBusiness = new CountryBusiness();
                record.LOG.MODIFYDATE     = DateTime.Now;
                record.LOG.MODIFYBYUSERID = sessioninfo.CurrentUserId;

                var updateRecord = _countryBusiness.UpdateTempCountryLimit(sessioninfo, record);

                return(new { Result = "OK", Record = updateRecord });
            }
            catch (Exception ex)
            {
                return(new { Result = "ERROR", Message = ex.Message });
            }
        }
Пример #15
0
        public static object GetCountryOptions(SessionInfo sessioninfo)
        {
            try
            {
                CountryBusiness _countryBusiness = new CountryBusiness();
                //Get data from database
                var countries = _countryBusiness.GetCountryAll()
                                .OrderBy(p => p.LABEL)
                                .Select(c => new { DisplayText = c.LABEL, Value = c.ID });

                //Return result to jTable
                return(new { Result = "OK", Options = countries });
            }
            catch (Exception ex)
            {
                return(new { Result = "ERROR", Message = ex.Message });
            }
        }
Пример #16
0
        public void Remove(int id)
        {
            try
            {
                var bc = new CountryBusiness();
                bc.Remove(id);
            }
            catch (Exception ex)
            {
                var httpError = new HttpResponseMessage()
                {
                    StatusCode   = (HttpStatusCode)422,
                    ReasonPhrase = ex.Message
                };

                throw new HttpResponseException(httpError);
            }
        }
Пример #17
0
        public Country Add(Country country)
        {
            try
            {
                var bc = new CountryBusiness();
                return(bc.Add(country));
            }
            catch (Exception ex)
            {
                var httpError = new HttpResponseMessage()
                {
                    StatusCode   = (HttpStatusCode)422,
                    ReasonPhrase = ex.Message
                };

                throw new HttpResponseException(httpError);
            }
        }
Пример #18
0
        public void Edit(Country country)
        {
            try
            {
                var bc = new CountryBusiness();
                country.ChangedOn = System.DateTime.Now;
                bc.Edit(country);
            }
            catch (Exception ex)
            {
                var httpError = new HttpResponseMessage()
                {
                    StatusCode   = (HttpStatusCode)422,
                    ReasonPhrase = ex.Message
                };

                throw new HttpResponseException(httpError);
            }
        }
Пример #19
0
        public FindResponseCountry Find(int id)
        {
            try
            {
                var response = new FindResponseCountry();
                var bc       = new CountryBusiness();
                response.Result = bc.Find(id);
                return(response);
            }
            catch (Exception ex)
            {
                var httpError = new HttpResponseMessage()
                {
                    StatusCode   = (HttpStatusCode)422,
                    ReasonPhrase = ex.Message
                };

                throw new HttpResponseException(httpError);
            }
        }
Пример #20
0
        public AllResponse <Country> All()
        {
            try
            {
                var response = new AllResponse <Country>();
                var bc       = new CountryBusiness();
                response.Result = bc.All();
                return(response);
            }
            catch (Exception ex)
            {
                var httpError = new HttpResponseMessage()
                {
                    StatusCode   = (HttpStatusCode)422,
                    ReasonPhrase = ex.Message
                };

                throw new HttpResponseException(httpError);
            }
        }
Пример #21
0
        public static object GetCountryLimitByCountryID(SessionInfo sessioninfo, Guid ID)
        {
            try
            {
                CountryBusiness _countryBusiness = new CountryBusiness();
                //Get data from database
                List <MA_COUNTRY_LIMIT> limits = _countryBusiness.GetCountryLimitByCountryID(sessioninfo, ID);

                //Return result to jTable
                return(new { Result = "OK", Records = limits, TotalRecordCount = limits.Count });
            }
            catch (BusinessWorkflowsException bex)
            {
                return(new { Result = "ERROR", Message = bex.Message });
            }
            catch (Exception ex)
            {
                return(new { Result = "ERROR", Message = ex.Message });
            }
        }
Пример #22
0
        public void GetAll_ReturnsACorrectListOfCountries_WhenThereAreCountries()
        {
            // Arrange
            var countries = new List <Country>
            {
                new Country {
                    Name = "TestCountry1", Id = 1
                },
                new Country {
                    Name = "TestCountry2", Id = 2
                },
                new Country {
                    Name = "TestCountry3", Id = 3
                },
            }.AsQueryable();

            var countryMockDbSet = new Mock <DbSet <Country> >();

            countryMockDbSet.As <IQueryable <Country> >().Setup(m => m.Provider).Returns(countries.Provider);
            countryMockDbSet.As <IQueryable <Country> >().Setup(m => m.Expression).Returns(countries.Expression);
            countryMockDbSet.As <IQueryable <Country> >().Setup(m => m.ElementType).Returns(countries.ElementType);
            countryMockDbSet.As <IQueryable <Country> >().Setup(m => m.GetEnumerator()).Returns(countries.GetEnumerator());

            var mockContext = new Mock <EazyCartContext>();

            mockContext.Setup(c => c.Countries).Returns(countryMockDbSet.Object);

            var countryBusiness = new CountryBusiness(mockContext.Object);

            // Act
            var allCountries = countryBusiness.GetAll();

            // Assert
            string expectedFirstCountryName  = "TestCountry1";
            string expectedSecondCountryName = "TestCountry2";
            string expectedThirdCountryName  = "TestCountry3";

            Assert.AreEqual(expectedFirstCountryName, allCountries[0].Name, "First names do not match.");
            Assert.AreEqual(expectedSecondCountryName, allCountries[1].Name, "Second names do not match.");
            Assert.AreEqual(expectedThirdCountryName, allCountries[2].Name, "Third names do not match");
        }
Пример #23
0
        public static object CreateTempLimit(SessionInfo sessioninfo, MA_COUNTRY_LIMIT record)
        {
            try
            {
                CountryBusiness _countryBusiness = new CountryBusiness();

                record.ID                 = Guid.NewGuid();
                record.ISTEMP             = true;
                record.FLAG_CONTROL       = true;
                record.LOG.INSERTDATE     = DateTime.Now;
                record.LOG.INSERTBYUSERID = sessioninfo.CurrentUserId;

                var addedRecord = _countryBusiness.CreateTempLimit(sessioninfo, record);

                return(new { Result = "OK", Record = addedRecord });
            }
            catch (Exception ex)
            {
                return(new { Result = "ERROR", Message = ex.Message });
            }
        }
Пример #24
0
        public void GetCountry_ReturnsACountry_WhichIsNotNull()
        {
            // Arrange
            var countries = new List <Country>
            {
                new Country {
                    Name = "TestCountry1", Id = 1
                },
                new Country {
                    Name = "TestCountry2", Id = 2
                },
                new Country {
                    Name = "TestCountry3", Id = 3
                },
            }.AsQueryable();

            var countryMockDbSet = new Mock <DbSet <Country> >();

            countryMockDbSet.As <IQueryable <Country> >().Setup(m => m.Provider).Returns(countries.Provider);
            countryMockDbSet.As <IQueryable <Country> >().Setup(m => m.Expression).Returns(countries.Expression);
            countryMockDbSet.As <IQueryable <Country> >().Setup(m => m.ElementType).Returns(countries.ElementType);
            countryMockDbSet.As <IQueryable <Country> >().Setup(m => m.GetEnumerator()).Returns(countries.GetEnumerator());

            var mockContext = new Mock <EazyCartContext>();

            mockContext.Setup(c => c.Countries).Returns(countryMockDbSet.Object);

            var countryBusiness = new CountryBusiness(mockContext.Object);

            // Act
            int idToGet = 2;
            var country = countryBusiness.Get(idToGet);

            // Assert
            string expectedCountryName = "TestCountry2";

            Assert.IsNotNull(country, "Country could not be extracted.");
            Assert.AreEqual(expectedCountryName, country.Name, "Names do not match.");
        }
Пример #25
0
 public BranchController(UserManager <ApplicationUser> userManager,
                         IHttpContextAccessor httpContextAccessor,
                         MardisContext mardisContext,
                         ILogger <BranchController> logger,
                         ILogger <ServicesFilterController> loggeFilter,
                         IMemoryCache memoryCache,
                         RedisCache distributedCache)
     : base(userManager, httpContextAccessor, mardisContext, logger)
 {
     TableName             = CBranch.TableName;
     ControllerName        = CBranch.Controller;
     _cache                = memoryCache;
     _branchBusiness       = new BranchBusiness(mardisContext);
     _branchImageBusiness  = new BranchImageBusiness(mardisContext);
     _taskCampaignBusiness = new TaskCampaignBusiness(mardisContext, distributedCache);
     _countryBusiness      = new CountryBusiness(mardisContext, memoryCache);
     _provinceBusiness     = new ProvinceBusiness(mardisContext, memoryCache);
     _districtBusiness     = new DistrictBusiness(mardisContext);
     _parishBusiness       = new ParishBusiness(mardisContext);
     _sectorBusiness       = new SectorBusiness(mardisContext);
     _smsBusiness          = new SmsBusiness(mardisContext);
 }
Пример #26
0
        public void AddCountry_ThrowsArgumentException_WhenIdIsDuplicate()
        {
            // Arrange
            int duplicateId = 1;
            var countries   = new List <Country>
            {
                new Country {
                    Name = "TestCountry1", Id = duplicateId
                },
            }.AsQueryable();

            var countryMockDbSet = new Mock <DbSet <Country> >();

            countryMockDbSet.As <IQueryable <Country> >().Setup(m => m.Provider).Returns(countries.Provider);
            countryMockDbSet.As <IQueryable <Country> >().Setup(m => m.Expression).Returns(countries.Expression);
            countryMockDbSet.As <IQueryable <Country> >().Setup(m => m.ElementType).Returns(countries.ElementType);
            countryMockDbSet.As <IQueryable <Country> >().Setup(m => m.GetEnumerator()).Returns(countries.GetEnumerator());

            var mockContext = new Mock <EazyCartContext>();

            mockContext.Setup(c => c.Countries).Returns(countryMockDbSet.Object);
            mockContext.Setup(c => c.SaveChanges()).Throws(new Exception());
            var countryBusiness = new CountryBusiness(mockContext.Object);

            // Act & Assert
            try
            {
                countryBusiness.Add("TestCountry1", duplicateId);
                Assert.Fail("No exception was thrown");
            }
            catch (ArgumentException exc)
            {
                string expectedMessage = string.Format("Country with ID {0} already exists.", duplicateId);
                Assert.AreEqual(expectedMessage, exc.Message, "Wrong exception is thrown");
            }
        }
Пример #27
0
        public static void Initialize(CSCDbContext dbContext)
        {
            dbContext.Database.EnsureCreated();

            if (dbContext.Users.Any())
            {
                return;
            }

            var users = new User[]
            {
                new User {
                    Name = "Michael", Surname = "Jackson", Email = "*****@*****.**", Address = "Indiana", Password = "******"
                },
                new User {
                    Name = "Arnold", Surname = "Schwarzenegger", Email = "*****@*****.**", Address = "Los Angeles", Password = "******"
                }
            };

            foreach (var user in users)
            {
                dbContext.Users.Add(user);
            }
            dbContext.SaveChanges();

            var organizations = new Organization[]
            {
                new Organization {
                    Name = "Samsung", Code = "S7", Type = OrganizationType.GeneralPartnership, User = users[0]
                },
                new Organization {
                    Name = "Vodafone", Code = "V8", Type = OrganizationType.IncorporatedCompany, User = users[0]
                },
                new Organization {
                    Name = "T-Mobile", Code = "TMB", Type = OrganizationType.LimitedLiabilityCompany, User = users[1]
                },
                new Organization {
                    Name = "AT&T branded", Code = "ATT", Type = OrganizationType.LimitedPartnership, User = users[1]
                },
                new Organization {
                    Name = "XAS", Code = "XAS", Type = OrganizationType.SocialEnterprise, User = users[1]
                }
            };

            foreach (var organization in organizations)
            {
                dbContext.Organizations.Add(organization);
            }
            dbContext.SaveChanges();

            var countries = new Country[]
            {
                new Country {
                    Name = "Afghanistan", Code = "AFG", Organization = organizations[0]
                },
                new Country {
                    Name = "Austria", Code = "TRG", Organization = organizations[0]
                },
                new Country {
                    Name = "Bulgaria", Code = "BGL", Organization = organizations[0]
                },
                new Country {
                    Name = "Croatia", Code = "CRO", Organization = organizations[0]
                },
                new Country {
                    Name = "Cyprus", Code = "CYY", Organization = organizations[4]
                },
                new Country {
                    Name = "Czech Republic", Code = "ETL", Organization = organizations[2]
                },
                new Country {
                    Name = "Greece", Code = "EUR", Organization = organizations[1]
                },
                new Country {
                    Name = "Hungary", Code = "XEH", Organization = organizations[3]
                },
                new Country {
                    Name = "Indonesia", Code = "XSE", Organization = organizations[4]
                },
                new Country {
                    Name = "Israel", Code = "ILO", Organization = organizations[2]
                },
                new Country {
                    Name = "Italy", Code = "ITV", Organization = organizations[1]
                },
                new Country {
                    Name = "Libya", Code = "BTC", Organization = organizations[3]
                },
                new Country {
                    Name = "Luxembourg", Code = "LUX", Organization = organizations[2]
                },
                new Country {
                    Name = "Montenegro", Code = "TMT", Organization = organizations[3]
                }
            };

            foreach (var country in countries)
            {
                dbContext.Countries.Add(country);
            }
            dbContext.SaveChanges();

            var businessTypes = new Business[]
            {
                new Business {
                    Name = "GIS"
                },
                new Business {
                    Name = "CEO"
                },
                new Business {
                    Name = "Telecommunication"
                },
                new Business {
                    Name = "Managed Services"
                }
            };

            foreach (var businessType in businessTypes)
            {
                dbContext.Businesses.Add(businessType);
            }
            dbContext.SaveChanges();

            var familyTypes = new Family[]
            {
                new Family {
                    Name = "Data Center", Business = businessTypes[0]
                },
                new Family {
                    Name = "Cloud", Business = businessTypes[0]
                },
                new Family {
                    Name = "Cyber", Business = businessTypes[1]
                },
                new Family {
                    Name = "Computer Networks", Business = businessTypes[2]
                },
                new Family {
                    Name = "Television Networks", Business = businessTypes[2]
                },
                new Family {
                    Name = "Business-to-business", Business = businessTypes[3]
                },
                new Family {
                    Name = "Marketing", Business = businessTypes[3]
                }
            };

            foreach (var familyType in familyTypes)
            {
                dbContext.Families.Add(familyType);
            }
            dbContext.SaveChanges();

            var offeringTypes = new Offering[]
            {
                new Offering {
                    Name = "Data Storage", Family = familyTypes[0]
                },
                new Offering {
                    Name = "Data management", Family = familyTypes[0]
                },
                new Offering {
                    Name = "Biz cloud", Family = familyTypes[1]
                },
                new Offering {
                    Name = "Cloud compute", Family = familyTypes[1]
                },
                new Offering {
                    Name = "Consulting services", Family = familyTypes[2]
                },
                new Offering {
                    Name = "Ethernet", Family = familyTypes[3]
                },
                new Offering {
                    Name = "Wireless networks", Family = familyTypes[3]
                },
                new Offering {
                    Name = "Cable television", Family = familyTypes[4]
                },
                new Offering {
                    Name = "Satellite television", Family = familyTypes[4]
                },
                new Offering {
                    Name = "Supply chain management", Family = familyTypes[5]
                },
                new Offering {
                    Name = "Videoconferencing", Family = familyTypes[5]
                },
                new Offering {
                    Name = "Marketing strategy", Family = familyTypes[6]
                },
                new Offering {
                    Name = "Integrated advertising agency services", Family = familyTypes[6]
                }
            };

            foreach (var offeringType in offeringTypes)
            {
                dbContext.Offerings.Add(offeringType);
            }
            dbContext.SaveChanges();

            var countryBusinesses = new CountryBusiness[]
            {
                new CountryBusiness {
                    Country = countries[0], Business = businessTypes[0]
                },
                new CountryBusiness {
                    Country = countries[1], Business = businessTypes[0]
                },
                new CountryBusiness {
                    Country = countries[1], Business = businessTypes[1]
                },
                new CountryBusiness {
                    Country = countries[2], Business = businessTypes[2]
                },
                new CountryBusiness {
                    Country = countries[3], Business = businessTypes[3]
                },
                new CountryBusiness {
                    Country = countries[3], Business = businessTypes[1]
                },
                new CountryBusiness {
                    Country = countries[4], Business = businessTypes[2]
                },
                new CountryBusiness {
                    Country = countries[5], Business = businessTypes[3]
                },
                new CountryBusiness {
                    Country = countries[6], Business = businessTypes[0]
                },
                new CountryBusiness {
                    Country = countries[6], Business = businessTypes[2]
                },
                new CountryBusiness {
                    Country = countries[6], Business = businessTypes[1]
                },
                new CountryBusiness {
                    Country = countries[8], Business = businessTypes[3]
                },
                new CountryBusiness {
                    Country = countries[9], Business = businessTypes[0]
                },
                new CountryBusiness {
                    Country = countries[9], Business = businessTypes[3]
                },
                new CountryBusiness {
                    Country = countries[10], Business = businessTypes[2]
                },
                new CountryBusiness {
                    Country = countries[12], Business = businessTypes[1]
                },
                new CountryBusiness {
                    Country = countries[12], Business = businessTypes[0]
                },
                new CountryBusiness {
                    Country = countries[12], Business = businessTypes[2]
                },
                new CountryBusiness {
                    Country = countries[13], Business = businessTypes[3]
                }
            };

            foreach (var countryBusiness in countryBusinesses)
            {
                dbContext.CountryBusinesses.Add(countryBusiness);
            }
            dbContext.SaveChanges();

            var businessFamilies = new BusinessFamily[]
            {
                new BusinessFamily {
                    CountryBusiness = countryBusinesses[0], Family = familyTypes[0]
                },
                new BusinessFamily {
                    CountryBusiness = countryBusinesses[0], Family = familyTypes[1]
                },
                new BusinessFamily {
                    CountryBusiness = countryBusinesses[1], Family = familyTypes[1]
                },
                new BusinessFamily {
                    CountryBusiness = countryBusinesses[2], Family = familyTypes[2]
                },
                new BusinessFamily {
                    CountryBusiness = countryBusinesses[3], Family = familyTypes[3]
                },
                new BusinessFamily {
                    CountryBusiness = countryBusinesses[4], Family = familyTypes[5]
                },
                new BusinessFamily {
                    CountryBusiness = countryBusinesses[4], Family = familyTypes[6]
                },
                new BusinessFamily {
                    CountryBusiness = countryBusinesses[6], Family = familyTypes[3]
                },
                new BusinessFamily {
                    CountryBusiness = countryBusinesses[7], Family = familyTypes[6]
                },
                new BusinessFamily {
                    CountryBusiness = countryBusinesses[8], Family = familyTypes[0]
                },
                new BusinessFamily {
                    CountryBusiness = countryBusinesses[9], Family = familyTypes[3]
                },
                new BusinessFamily {
                    CountryBusiness = countryBusinesses[9], Family = familyTypes[4]
                },
                new BusinessFamily {
                    CountryBusiness = countryBusinesses[11], Family = familyTypes[5]
                },
                new BusinessFamily {
                    CountryBusiness = countryBusinesses[12], Family = familyTypes[1]
                },
                new BusinessFamily {
                    CountryBusiness = countryBusinesses[13], Family = familyTypes[6]
                },
                new BusinessFamily {
                    CountryBusiness = countryBusinesses[14], Family = familyTypes[3]
                },
                new BusinessFamily {
                    CountryBusiness = countryBusinesses[14], Family = familyTypes[4]
                },
                new BusinessFamily {
                    CountryBusiness = countryBusinesses[16], Family = familyTypes[0]
                },
                new BusinessFamily {
                    CountryBusiness = countryBusinesses[17], Family = familyTypes[4]
                },
                new BusinessFamily {
                    CountryBusiness = countryBusinesses[18], Family = familyTypes[5]
                }
            };

            foreach (var businessFamily in businessFamilies)
            {
                dbContext.BusinessFamilies.Add(businessFamily);
            }
            dbContext.SaveChanges();

            var familyOfferings = new FamilyOffering[]
            {
                new FamilyOffering {
                    BusinessFamily = businessFamilies[0], Offering = offeringTypes[0]
                },
                new FamilyOffering {
                    BusinessFamily = businessFamilies[1], Offering = offeringTypes[2]
                },
                new FamilyOffering {
                    BusinessFamily = businessFamilies[2], Offering = offeringTypes[3]
                },
                new FamilyOffering {
                    BusinessFamily = businessFamilies[3], Offering = offeringTypes[4]
                },
                new FamilyOffering {
                    BusinessFamily = businessFamilies[5], Offering = offeringTypes[9]
                },
                new FamilyOffering {
                    BusinessFamily = businessFamilies[5], Offering = offeringTypes[10]
                },
                new FamilyOffering {
                    BusinessFamily = businessFamilies[6], Offering = offeringTypes[11]
                },
                new FamilyOffering {
                    BusinessFamily = businessFamilies[7], Offering = offeringTypes[5]
                },
                new FamilyOffering {
                    BusinessFamily = businessFamilies[8], Offering = offeringTypes[11]
                },
                new FamilyOffering {
                    BusinessFamily = businessFamilies[8], Offering = offeringTypes[12]
                },
                new FamilyOffering {
                    BusinessFamily = businessFamilies[10], Offering = offeringTypes[6]
                },
                new FamilyOffering {
                    BusinessFamily = businessFamilies[11], Offering = offeringTypes[7]
                },
                new FamilyOffering {
                    BusinessFamily = businessFamilies[12], Offering = offeringTypes[9]
                },
                new FamilyOffering {
                    BusinessFamily = businessFamilies[13], Offering = offeringTypes[2]
                },
                new FamilyOffering {
                    BusinessFamily = businessFamilies[13], Offering = offeringTypes[3]
                },
                new FamilyOffering {
                    BusinessFamily = businessFamilies[15], Offering = offeringTypes[5]
                },
                new FamilyOffering {
                    BusinessFamily = businessFamilies[16], Offering = offeringTypes[8]
                },
                new FamilyOffering {
                    BusinessFamily = businessFamilies[17], Offering = offeringTypes[1]
                },
                new FamilyOffering {
                    BusinessFamily = businessFamilies[18], Offering = offeringTypes[7]
                },
                new FamilyOffering {
                    BusinessFamily = businessFamilies[18], Offering = offeringTypes[8]
                },
                new FamilyOffering {
                    BusinessFamily = businessFamilies[19], Offering = offeringTypes[10]
                }
            };

            foreach (var familyOffering in familyOfferings)
            {
                dbContext.FamilyOfferings.Add(familyOffering);
            }
            dbContext.SaveChanges();

            var departments = new Department[]
            {
                new Department {
                    Name = "Departmetnt 1", FamilyOffering = familyOfferings[0]
                },
                new Department {
                    Name = "Departmetnt 2", FamilyOffering = familyOfferings[1]
                },
                new Department {
                    Name = "Departmetnt 3", FamilyOffering = familyOfferings[1]
                },
                new Department {
                    Name = "Departmetnt 4", FamilyOffering = familyOfferings[2]
                },
                new Department {
                    Name = "Departmetnt 5", FamilyOffering = familyOfferings[2]
                },
                new Department {
                    Name = "Departmetnt 6", FamilyOffering = familyOfferings[2]
                },
                new Department {
                    Name = "Departmetnt 7", FamilyOffering = familyOfferings[4]
                },
                new Department {
                    Name = "Departmetnt 8", FamilyOffering = familyOfferings[5]
                },
                new Department {
                    Name = "Departmetnt 9", FamilyOffering = familyOfferings[6]
                },
                new Department {
                    Name = "Departmetnt 10", FamilyOffering = familyOfferings[7]
                },
                new Department {
                    Name = "Departmetnt 11", FamilyOffering = familyOfferings[7]
                },
                new Department {
                    Name = "Departmetnt 12", FamilyOffering = familyOfferings[7]
                },
                new Department {
                    Name = "Departmetnt 13", FamilyOffering = familyOfferings[9]
                },
                new Department {
                    Name = "Departmetnt 14", FamilyOffering = familyOfferings[10]
                },
                new Department {
                    Name = "Departmetnt 15", FamilyOffering = familyOfferings[11]
                },
                new Department {
                    Name = "Departmetnt 16", FamilyOffering = familyOfferings[11]
                },
                new Department {
                    Name = "Departmetnt 17", FamilyOffering = familyOfferings[13]
                },
                new Department {
                    Name = "Departmetnt 18", FamilyOffering = familyOfferings[14]
                },
                new Department {
                    Name = "Departmetnt 19", FamilyOffering = familyOfferings[15]
                },
                new Department {
                    Name = "Departmetnt 20", FamilyOffering = familyOfferings[17]
                },
                new Department {
                    Name = "Departmetnt 21", FamilyOffering = familyOfferings[17]
                },
                new Department {
                    Name = "Departmetnt 22", FamilyOffering = familyOfferings[17]
                },
                new Department {
                    Name = "Departmetnt 23", FamilyOffering = familyOfferings[19]
                },
                new Department {
                    Name = "Departmetnt 24", FamilyOffering = familyOfferings[20]
                },
                new Department {
                    Name = "Departmetnt 25", FamilyOffering = familyOfferings[20]
                }
            };

            foreach (var department in departments)
            {
                dbContext.Departments.Add(department);
            }
            dbContext.SaveChanges();
        }
Пример #28
0
        public List <LimitAuditReportModel> GetLimitAuditReport(SessionInfo sessionInfo, string strLogDatefrom, string strLogDateto, string strCtpy, string strCountry, string strEvent)
        {
            try
            {
                DateTime             dteReportfrom;
                DateTime             dteReportto;
                Guid                 guCtpyID              = Guid.Empty;
                Guid                 guCountryID           = Guid.Empty;
                LogBusiness          _logBusiness          = new LogBusiness();
                CounterpartyBusiness _counterpartyBusiness = new CounterpartyBusiness();
                CountryBusiness      _countryBusiness      = new CountryBusiness();
                UserBusiness         _userBusiness         = new UserBusiness();

                var log = _logBusiness.GetLogAll().Where(l => l.EVENT == LimitLogEvent.LIMIT_AUDIT.ToString() ||
                                                         l.EVENT == LimitLogEvent.TEMP_LIMIT_AUDIT.ToString() ||
                                                         l.EVENT == LimitLogEvent.COUNTRY_LIMIY_AUDIT.ToString() ||
                                                         l.EVENT == LimitLogEvent.TEMP_COUNTRY_LIMIT_AUDIT.ToString()).AsQueryable();

                var ctpyLimit = _counterpartyBusiness.GetCounterpartyLimitAll().AsQueryable();
                var ctpys     = _counterpartyBusiness.GetCounterpartyAll().AsQueryable();
                var countrys  = _countryBusiness.GetCountryAll().AsQueryable();
                var users     = _userBusiness.GetAll().AsQueryable();

                if (String.IsNullOrEmpty(strLogDatefrom))
                {
                    throw this.CreateException(new Exception(), "Please input start log date.");
                }
                else if (!DateTime.TryParseExact(strLogDatefrom, "dd/MM/yyyy", null, DateTimeStyles.None, out dteReportfrom))
                {
                    throw this.CreateException(new Exception(), "Invalid start log date.");
                }
                else
                {
                    dteReportfrom = DateTime.ParseExact(strLogDatefrom, "dd/MM/yyyy", null);
                }

                if (String.IsNullOrEmpty(strLogDateto))
                {
                    throw this.CreateException(new Exception(), "Please input end log date.");
                }
                else if (!DateTime.TryParseExact(strLogDateto, "dd/MM/yyyy", null, DateTimeStyles.None, out dteReportto))
                {
                    throw this.CreateException(new Exception(), "Invalid end log date.");
                }
                else
                {
                    dteReportto = DateTime.ParseExact(strLogDateto, "dd/MM/yyyy", null);
                }
                if (dteReportto < dteReportfrom)
                {
                    throw this.CreateException(new Exception(), "Start log date must before end log date.");
                }

                var limits = from limit in ctpyLimit
                             join ctpy in ctpys on limit.CTPY_ID equals ctpy.ID
                             select new
                {
                    LIMIT_ID = limit.ID,
                    CTPY_ID  = ctpy.ID,
                    SNAME    = ctpy.SNAME,
                    LIMIT    = limit.MA_LIMIT.LABEL
                };

                log = log.Where(l => l.LOG_DATE.Date >= dteReportfrom.Date && l.LOG_DATE.Date <= dteReportto.Date);

                if (strEvent != "-1")
                {
                    log = log.Where(p => p.EVENT == strEvent);
                }

                var limitAudits = from l in log
                                  join user in users on l.LOG.INSERTBYUSERID equals user.ID
                                  join c in limits on l.RECORD_ID equals c.LIMIT_ID into templimit
                                  from sublimit in templimit.DefaultIfEmpty()
                                  join country in countrys on l.RECORD_ID equals country.ID into tempcountry
                                  from subcountry in tempcountry.DefaultIfEmpty()
                                  orderby l.LOG_DATE
                                  select new LimitAuditReportModel
                {
                    ENTITY       = sublimit != null ? sublimit.SNAME : subcountry != null ? subcountry.LABEL : "",
                    ENTITY_ID    = sublimit != null ? sublimit.CTPY_ID : (subcountry != null ? subcountry.ID : Guid.Empty),
                    LIMIT        = (l.EVENT.Contains("TEMP") ? "TEMP-" : "") + (sublimit != null ? sublimit.LIMIT : "COUNTRY-LIMIT"),            //sublimit != null ? sublimit.LIMIT : "Country Limit",
                    USER         = user.USERCODE,
                    LOG_DATE     = l.LOG_DATE,
                    LOG_DATE_STR = l.LOG_DATE.ToString("dd-MMM-yyyy HH:mm"),
                    DETAIL       = l.LOG_DETAIL
                };

                if (Guid.TryParse(strCtpy, out guCtpyID))
                {
                    guCtpyID    = Guid.Parse(strCtpy);
                    limitAudits = limitAudits.Where(p => p.ENTITY_ID == guCtpyID);
                }

                if (Guid.TryParse(strCountry, out guCountryID))
                {
                    guCountryID = Guid.Parse(strCountry);
                    limitAudits = limitAudits.Where(t => t.ENTITY_ID == guCountryID);
                }

                return(limitAudits.ToList());
            }
            catch (DataServicesException ex)
            {
                throw this.CreateException(ex, null);
            }
        }
Пример #29
0
        public List <LimitCheckModel> GetCountryReport(SessionInfo sessioninfo, string strReportDate, string strCountry, string strSource, string strStatus)
        {
            try
            {
                DateTime             dteReport;
                LimitCheckBusiness   _limitBusiness        = new LimitCheckBusiness();
                DealBusiness         _dealBusiness         = new DealBusiness();
                CounterpartyBusiness _counterpartyBusiness = new CounterpartyBusiness();
                CountryBusiness      _countryBusiness      = new CountryBusiness();
                Guid             guCountryID = Guid.Empty;
                MA_COUNTRY_LIMIT temp_limit  = null;

                if (String.IsNullOrEmpty(strReportDate))
                {
                    throw this.CreateException(new Exception(), "Please input report date.");
                }
                else if (!DateTime.TryParseExact(strReportDate, "dd/MM/yyyy", null, DateTimeStyles.None, out dteReport))
                {
                    throw this.CreateException(new Exception(), "Invalid report date.");
                }
                else
                {
                    dteReport = DateTime.ParseExact(strReportDate, "dd/MM/yyyy", null);
                }

                if (_dealBusiness.CountByProcessDate(dteReport) == 0)
                {
                    throw this.CreateException(new Exception(), "No data for selected report date.");
                }

                if (Guid.TryParse(strCountry, out guCountryID))
                {
                    guCountryID = Guid.Parse(strCountry);
                }

                List <LimitCheckModel> sets = _limitBusiness.GetCountrySETByCriteria(dteReport, guCountryID, strSource, Guid.Empty, Guid.Empty);
                List <LimitCheckModel> pces = _limitBusiness.GetCountryPCEByCriteria(dteReport, guCountryID, strSource, Guid.Empty, Guid.Empty);

                var reports = (from report in sets.Union(pces)
                               join pce in pces on report.COUNTRY_ID equals pce.COUNTRY_ID
                               select new LimitCheckModel
                {
                    COUNTRY_LABEL = report.COUNTRY_LABEL,
                    COUNTRY_ID = report.COUNTRY_ID,
                    FLAG_CONTROL = report.FLAG_CONTROL,
                    GEN_AMOUNT = report.AMOUNT,
                    PROCESSING_DATE = report.PROCESSING_DATE,
                    EXPIRE_DATE = report.EXPIRE_DATE,
                    FLOW_DATE = report.FLOW_DATE,
                    SET_CONTRIBUTE = report.SET_CONTRIBUTE,
                    PCE_CONTRIBUTE = pce.PCE_CONTRIBUTE
                }).GroupBy(g => new
                {
                    g.COUNTRY_ID,
                    g.COUNTRY_LABEL,
                    g.FLAG_CONTROL,
                    g.GEN_AMOUNT,
                    g.PROCESSING_DATE,
                    g.EXPIRE_DATE,
                    g.FLOW_DATE,
                    g.PCE_CONTRIBUTE
                }).Select(s => new LimitCheckModel
                {
                    COUNTRY_LABEL          = s.Key.COUNTRY_LABEL,
                    COUNTRY_ID             = s.Key.COUNTRY_ID,
                    FLAG_CONTROL           = s.Key.FLAG_CONTROL,
                    GEN_AMOUNT             = s.Key.GEN_AMOUNT,
                    PROCESSING_DATE        = s.Key.PROCESSING_DATE,
                    EXPIRE_DATE            = s.Key.EXPIRE_DATE,
                    FLOW_DATE              = s.Key.FLOW_DATE,
                    PCE_CONTRIBUTE         = s.Key.PCE_CONTRIBUTE,
                    SET_CONTRIBUTE         = s.Sum(x => x.SET_CONTRIBUTE),
                    ORIGINAL_KK_CONTRIBUTE = s.Key.PCE_CONTRIBUTE + s.Sum(y => y.SET_CONTRIBUTE)
                }).ToList();

                foreach (var report in reports)
                {
                    temp_limit = _countryBusiness.GetActiveTempByCountryID(sessioninfo.Process.CurrentDate, report.FLOW_DATE, report.COUNTRY_ID);

                    if (temp_limit != null)
                    {
                        report.TEMP_AMOUNT = temp_limit.AMOUNT;
                    }
                }

                if (strStatus != "")
                {
                    reports = reports.Where(t => t.STATUS.IndexOf(strStatus, StringComparison.OrdinalIgnoreCase) >= 0).ToList();
                }

                return(reports.OrderBy(p => p.COUNTRY_LABEL).ThenBy(t => t.FLOW_DATE).ToList());
            }

            catch (DataServicesException ex)
            {
                throw this.CreateException(ex, null);
            }
        }
Пример #30
0
        public void GetNameBySupplier_ReturnsACorrectCountry()
        {
            // Arrange
            var countries = new List <Country>()
            {
                new Country()
                {
                    Id = 1, Name = "TestCountry1"
                },
                new Country()
                {
                    Id = 2, Name = "TestCountry2"
                },
            }.AsQueryable();

            var cities = new List <City>()
            {
                new City()
                {
                    Id = 1, Name = "TestCity1", CountryId = 1
                },
                new City()
                {
                    Id = 2, Name = "TestCity2", CountryId = 2
                },
            }.AsQueryable();

            var suppliers = new List <Supplier>()
            {
                new Supplier()
                {
                    Id = 1, Name = "TestSupplier1", CityId = 1
                },
                new Supplier()
                {
                    Id = 2, Name = "TestSupplier2", CityId = 2
                },
            }.AsQueryable();

            var countryMockDbSet = new Mock <DbSet <Country> >();

            countryMockDbSet.As <IQueryable <Country> >().Setup(m => m.Provider).Returns(countries.Provider);
            countryMockDbSet.As <IQueryable <Country> >().Setup(m => m.Expression).Returns(countries.Expression);
            countryMockDbSet.As <IQueryable <Country> >().Setup(m => m.ElementType).Returns(countries.ElementType);
            countryMockDbSet.As <IQueryable <Country> >().Setup(m => m.GetEnumerator()).Returns(countries.GetEnumerator());

            var cityMockDbSet = new Mock <DbSet <City> >();

            cityMockDbSet.As <IQueryable <City> >().Setup(m => m.Provider).Returns(cities.Provider);
            cityMockDbSet.As <IQueryable <City> >().Setup(m => m.Expression).Returns(cities.Expression);
            cityMockDbSet.As <IQueryable <City> >().Setup(m => m.ElementType).Returns(cities.ElementType);
            cityMockDbSet.As <IQueryable <City> >().Setup(m => m.GetEnumerator()).Returns(cities.GetEnumerator());

            var supplierMockDbSet = new Mock <DbSet <Supplier> >();

            supplierMockDbSet.As <IQueryable <Supplier> >().Setup(m => m.Provider).Returns(suppliers.Provider);
            supplierMockDbSet.As <IQueryable <Supplier> >().Setup(m => m.Expression).Returns(suppliers.Expression);
            supplierMockDbSet.As <IQueryable <Supplier> >().Setup(m => m.ElementType).Returns(suppliers.ElementType);
            supplierMockDbSet.As <IQueryable <Supplier> >().Setup(m => m.GetEnumerator()).Returns(suppliers.GetEnumerator());

            var mockContext = new Mock <EazyCartContext>();

            mockContext.Setup(c => c.Countries).Returns(countryMockDbSet.Object);
            mockContext.Setup(c => c.Cities).Returns(cityMockDbSet.Object);
            mockContext.Setup(c => c.Suppliers).Returns(supplierMockDbSet.Object);

            var countryBusiness = new CountryBusiness(mockContext.Object);

            // Act
            string supplierName      = "TestSupplier1";
            string actualCountryName = countryBusiness.GetNameBySupplier(supplierName);

            // Assert
            string expectedCountryName = "TestCountry1";

            Assert.AreEqual(expectedCountryName, actualCountryName, "Country names do not match.");
        }