public int GetCompanyIdForType(CompanyTypeEnum companyType)
        {
            int returned = 0;

            if (companyType == CompanyTypeEnum.Corporate)
            {
                var companyTypeId =
                    DataContext.CompanyTypes.FirstOrDefault(d => d.CompanyTypeName == companyType.ToString());
                if (companyTypeId == null)
                {
                    throw new InvalidOperationException("Corporate CompanyType not found");
                }
                returned = companyTypeId.CompanyTypeId;
            }
            if (companyType == CompanyTypeEnum.Licensee)
            {
                var companyTypeId =
                    DataContext.CompanyTypes.FirstOrDefault(d => d.CompanyTypeName == companyType.ToString());
                if (companyTypeId == null)
                {
                    throw new InvalidOperationException("Liscensee CompanyType not found");
                }
                returned = companyTypeId.CompanyTypeId;
            }
            return(returned);
        }
 public CompanyItem(int Id, string Name, int CountryCode, CompanyTypeEnum CompanyType)
 {
     this.Id              = Id;
     this.Name            = Name;
     this.ContryCode      = ContryCode;
     this.CompanyTypeEnum = CompanyType;
 }
Ejemplo n.º 3
0
        public ActionResult BuyCM(long houseID, PagingParam pagingParam)
        {
            var house = houseRepository.GetById(houseID);

            var result = houseService.CanViewHouse(house, SessionHelper.CurrentEntity);

            if (result.IsError)
            {
                return(RedirectBackWithError(result));
            }

            int[]                         availableProducts = { (int)ProductTypeEnum.ConstructionMaterials, (int)ProductTypeEnum.UpgradePoints };
            CompanyTypeEnum[]             companies         = new CompanyTypeEnum[] { CompanyTypeEnum.Manufacturer };
            IQueryable <MarketOfferModel> offers            = marketOfferRepository.GetAvailableOffers(0, 1, house.Region.Country, companies, availableProducts);

            if (offers.Count() > 0)
            {
                offers = offers.Apply(pagingParam);
            }


            var vm = new HouseBuyCMViewModel(house, pagingParam, offers, houseService.GetHouseRights(house, SessionHelper.CurrentEntity));

            return(View(vm));
        }
Ejemplo n.º 4
0
        public ActionResult ResourceOffers(int countryID, PagingParam pagingParam, int productID, int quality)
        {
            pagingParam = pagingParam ?? new PagingParam();

            var country = countryRepository.GetById(countryID);

            if (country == null)
            {
                return(RedirectToHomeWithError("Country does not exist!"));
            }


            int[] availableProducts = { (int)ProductTypeEnum.Bread,    (int)ProductTypeEnum.MovingTicket, (int)ProductTypeEnum.Tea,                (int)ProductTypeEnum.Weapon, ProductTypeEnum.Fuel.ToInt(),
                                        ProductTypeEnum.Grain.ToInt(), ProductTypeEnum.Iron.ToInt(),      ProductTypeEnum.MedicalSupplies.ToInt(), ProductTypeEnum.Oil.ToInt(), ProductTypeEnum.TeaLeaf.ToInt(),ProductTypeEnum.Wood.ToInt(),
                                        ProductTypeEnum.Paper.ToInt(), ProductTypeEnum.ConstructionMaterials.ToInt() };

            CompanyTypeEnum[]             companies = new CompanyTypeEnum[] { CompanyTypeEnum.Manufacturer, CompanyTypeEnum.Producer };
            IQueryable <MarketOfferModel> offers    = marketOfferRepository.GetAvailableOffers(productID, quality, country, companies, availableProducts);

            if (offers.Count() > 0)
            {
                offers = offers.Apply(pagingParam);
            }

            var countries = countryRepository.GetAll().ToList();


            var vm = new CountryMarketOffersListViewModel(SessionHelper.CurrentEntity, country, offers.ToList(), countries, availableProducts, pagingParam, quality, productID);

            return(View("MarketOffers", vm));
        }
Ejemplo n.º 5
0
        public ActionResult MakeDelivery(int hotelID, PagingParam pagingParam, int productID, int quality)
        {
            pagingParam = pagingParam ?? new PagingParam();

            var hotel = hotelRepository.GetById(hotelID);

            var result = hotelService.CanMakeDeliveries(hotel, SessionHelper.CurrentEntity);

            if (result.IsError)
            {
                return(RedirectBackWithError(result));
            }

            int[] availableProducts = { (int)ProductTypeEnum.Fuel, (int)ProductTypeEnum.ConstructionMaterials };

            CompanyTypeEnum[]             companies = new CompanyTypeEnum[] { CompanyTypeEnum.Manufacturer };
            IQueryable <MarketOfferModel> offers    = marketOfferRepository.GetAvailableOffers(productID, quality, hotel.Region.Country, companies, availableProducts);

            if (offers.Count() > 0)
            {
                offers = offers.Apply(pagingParam);
            }

            var rights = hotelService.GetHotelRigths(hotel, SessionHelper.CurrentEntity);
            var info   = hotelRepository.GetHotelInfo(hotelID, SessionHelper.CurrentEntity.EntityID);
            var vm     = new HotelMakeDeliveryViewModel(info, hotel, rights, offers, pagingParam, quality, productID);

            return(View(vm));
        }
Ejemplo n.º 6
0
        public ActionResult MarketOffers(int countryID, PagingParam pagingParam, int productID, int quality)
        {
            pagingParam = pagingParam ?? new PagingParam();

            var country = countryRepository.GetById(countryID);

            if (country == null)
            {
                return(RedirectToHomeWithError("Country does not exist!"));
            }
            int[] availableProducts = { (int)ProductTypeEnum.Bread, (int)ProductTypeEnum.MovingTicket, (int)ProductTypeEnum.Tea, (int)ProductTypeEnum.Weapon };

            CompanyTypeEnum[]             companies = new CompanyTypeEnum[] { CompanyTypeEnum.Shop };
            IQueryable <MarketOfferModel> offers    = marketOfferRepository.GetAvailableOffers(productID, quality, country, companies, availableProducts);

            if (offers.Count() > 0)
            {
                offers = offers.Apply(pagingParam);
            }

            var countries = countryRepository.GetAll().ToList();


            var vm = new CountryMarketOffersListViewModel(SessionHelper.CurrentEntity, country, offers.ToList(), countries, availableProducts, pagingParam, quality, productID);

            return(View(vm));
        }
Ejemplo n.º 7
0
        public static Payment GetPayment(long id, string paymentType, CompanyTypeEnum companyType)
        {
            using (var context = new BackofficeUnitOfWork())
            {
                switch (companyType)
                {
                case CompanyTypeEnum.GARAGE:
                    return(context.Payment
                           .Fetch()
                           .Include(i => i.PaymentType)
                           .Include(i => i.PaymentStatus)
                           .Where(i => i.ID_Garage == id && i.PaymentType.Token == paymentType && i.Active)
                           .FirstOrDefault());

                case CompanyTypeEnum.CONSTRUCTION_COMPANY:
                    return(context.Payment
                           .Fetch()
                           .Include(i => i.PaymentType)
                           .Include(i => i.PaymentStatus)
                           .Where(i => i.ID_ConstructionCompany == id && i.PaymentType.Token == paymentType && i.Active)
                           .FirstOrDefault());

                case CompanyTypeEnum.HOME_APPLIANCES_REPAIR:
                    return(context.Payment
                           .Fetch()
                           .Include(i => i.PaymentType)
                           .Include(i => i.PaymentStatus)
                           .Where(i => i.ID_HomeApplianceRepair == id && i.PaymentType.Token == paymentType && i.Active)
                           .FirstOrDefault());

                case CompanyTypeEnum.INSURANCE_COMPANY_CONTACT:
                    return(context.Payment
                           .Fetch()
                           .Include(i => i.PaymentType)
                           .Include(i => i.PaymentStatus)
                           .Where(i => i.ID_InsuranceCompanyContact == id && i.PaymentType.Token == paymentType && i.Active)
                           .FirstOrDefault());

                case CompanyTypeEnum.MEDICAL_CLINIC:
                    return(context.Payment
                           .Fetch()
                           .Include(i => i.PaymentType)
                           .Include(i => i.PaymentStatus)
                           .Where(i => i.ID_MedicalClinic == id && i.PaymentType.Token == paymentType && i.Active)
                           .FirstOrDefault());

                default:
                    return(context.Payment
                           .Fetch()
                           .Include(i => i.PaymentType)
                           .Include(i => i.PaymentStatus)
                           .Where(i => i.ID_Profile == id && i.PaymentType.Token == paymentType && i.Active)
                           .FirstOrDefault());
                }
            }
        }
Ejemplo n.º 8
0
        public static CompanyType GetCompanyType(CompanyTypeEnum type)
        {
            using (var context = new BackofficeUnitOfWork())
            {
                string companyType = type.ToString();

                return(context.CompanyType
                       .Fetch()
                       .Where(i => i.Token == companyType && i.Active)
                       .FirstOrDefault());
            }
        }
Ejemplo n.º 9
0
        private void ProcessUser(string employeeId, string redirectUrl, CompanyTypeEnum companyType)
        {
            using (var dataAccess = new UsersAndRolesDataAccess())
            {
                var companyTypeId = dataAccess.GetCompanyIdForType(companyType);
                var userEnitty    = dataAccess.GetUserEntityByEmployeeId(employeeId);

                if (userEnitty == null)             //User doesn't exist
                {
                    var userEntity = new UserEntity
                    {
                        EmployeeId    = employeeId,
                        CompanyTypeId = companyTypeId,
                        CompanyId     = null
                    };

                    var insertResult = dataAccess.AddMarsUserEntry(userEntity);
                    if (companyType == CompanyTypeEnum.Corporate)
                    {
                        if (insertResult == string.Empty)
                        {
                            Response.Redirect(redirectUrl);
                        }
                        else
                        {
                            lblMessage.Text = insertResult;
                        }
                    }
                    else            //Newly created Lisencee, needs Company
                    {
                        lblMessage.Text = NotInActiveDirectoy;
                    }
                }
                else                                //User does exist
                {
                    if (userEnitty.CompanyTypeId != companyTypeId)
                    {
                        dataAccess.ChangeUserCompanyType(userEnitty.MarsUserId, companyTypeId);
                    }

                    if (companyType == CompanyTypeEnum.Licensee && userEnitty.CompanyId == null)
                    {
                        pnlCountryAdmin.Visible = true;
                        lblMessage.Text         = LicenceeUserNeedsCompany;
                        return;
                    }

                    Response.Redirect(redirectUrl);
                }
            }
        }
Ejemplo n.º 10
0
 /// <summary>
 /// Returns the path of the company type background.
 /// </summary>
 /// <param name="type">Company type enum.</param>
 /// <returns>Path of background type.</returns>
 private string getcompanyTypeBackground(CompanyTypeEnum type)
 {
     if (type == CompanyTypeEnum.Retailer || type == CompanyTypeEnum.Dealership)
     {
         return(CommonImageSource.GetCompanyTypeBackgroundIcon(CompanyColorEnum.Green));
     }
     else if (type == CompanyTypeEnum.OffRoad)
     {
         return(CommonImageSource.GetCompanyTypeBackgroundIcon(CompanyColorEnum.Blue));
     }
     else
     {
         return(string.Empty);
     }
 }
Ejemplo n.º 11
0
        /// <summary>
        /// Gets the color of company type background.
        /// </summary>
        /// <param name="type">Company type enum.</param>
        /// <returns>String path of company type background.</returns>
        private string getCompanyTypeTextBackground(CompanyTypeEnum type)
        {
            switch (type)
            {
            case CompanyTypeEnum.Retailer:
            case CompanyTypeEnum.Dealership:
                return(RealRider.Core.Common.Constants.GreenCompanyBackgroundText);

            case CompanyTypeEnum.OffRoad:
                return(RealRider.Core.Common.Constants.BlueCompanyBackgroundText);

            default:
                return(string.Empty);
            }
        }
Ejemplo n.º 12
0
        public static List <ProductTypeEnum> GetSellableProducts(CompanyTypeEnum companyType)
        {
            switch (companyType)
            {
            case CompanyTypeEnum.Manufacturer:
                return(ProductGroups.Manufactured);

            case CompanyTypeEnum.Shop:
                return(ProductGroups.Consumables);

            case CompanyTypeEnum.Producer:
                return(ProductGroups.Raws);
            }

            return(new List <ProductTypeEnum>());
        }
Ejemplo n.º 13
0
        /// <summary>
        /// Gets the company type text.
        /// </summary>
        /// <param name="type">Company type enum.</param>
        /// <returns>String of company type.</returns>
        private string getCompanyTypeText(CompanyTypeEnum type)
        {
            switch (type)
            {
            case CompanyTypeEnum.Retailer:
                return(RealRider.Core.Common.Constants.GeneralRetailerText);

            case CompanyTypeEnum.OffRoad:
                return(RealRider.Core.Common.Constants.OffRoadText);

            case CompanyTypeEnum.Dealership:
                return(RealRider.Core.Common.Constants.DealershipText);

            default:
                return(string.Empty);
            }
        }
Ejemplo n.º 14
0
        public static List <ListItem> GetCompanyServices(CompanyTypeEnum type)
        {
            using (var context = new BackofficeUnitOfWork())
            {
                string companyType = type.ToString();

                return(context.CompanyService
                       .Fetch()
                       .Include(i => i.CompanyType)
                       .Where(i => i.CompanyType.Token == companyType && i.Active)
                       .Select(i => new ListItem()
                {
                    Key = i.ID, Value = i.Description
                })
                       .ToList());
            }
        }
Ejemplo n.º 15
0
        /// <summary>
        /// Gets the company icon path, based on company type enum.
        /// </summary>
        /// <param name="companyTypeEnum">CompanyType enum.</param>
        /// <returns></returns>
        public static string GetCompanyTypeIcon(CompanyTypeEnum companyTypeEnum)
        {
            switch (companyTypeEnum)
            {
            case CompanyTypeEnum.Retailer:
                return(Constants.RetailerCompanyType);

            case CompanyTypeEnum.OffRoad:
                return(Constants.FlagCompanyType);

            case CompanyTypeEnum.Dealership:
                return(Constants.BikeCompanyType);

            default:
                return(string.Empty);
            }
        }
Ejemplo n.º 16
0
        public List <PageEntity> GetPagesForRole(int roleId, CompanyTypeEnum companyType)
        {
            var accessData = from ma in DataContext.MarsUserRoleMenuAccesses
                             where ma.MarsUserRoleId == roleId
                             select ma;

            var baseAccess = from ma in DataContext.MarsUserRoleMenuAccesses
                             where ma.MarsUserRole.BaseAccess &&
                             ma.MarsUserRole.CompanyType.CompanyTypeName == companyType.ToString()
                             select ma;


            var loggedOnEmployee = ApplicationAuthentication.GetEmployeeId();

            var userHasSysAdmin = DataContext.MarsUserUserRoles.FirstOrDefault(
                d => d.MarsUser.EmployeeId == loggedOnEmployee &&
                d.MarsUserRole.AdminAccess);



            var roleData = from rm in DataContext.RibbonMenus
                           join ad in accessData on rm.UrlId equals ad.UrlId into joinedData
                           from jd in joinedData.DefaultIfEmpty()
                           join ba in baseAccess on rm.UrlId equals ba.UrlId into joinedBaseData
                           from jbd in joinedBaseData.DefaultIfEmpty()
                           where rm.ParentId != null &&
                           rm.Enabled.HasValue && rm.Enabled.Value
                           select new PageEntity
            {
                UrlId         = rm.UrlId,
                PageName      = rm.Title,
                Url           = rm.Url,
                Assigned      = jd != null,
                IsBranch      = rm.ParentId == 1,
                BaseHasAccess = jbd != null,
                ParentId      = rm.ParentId.HasValue ? rm.ParentId.Value : 0,
                Enabled       = userHasSysAdmin != null,
                MenuId        = rm.MenuId.HasValue ? rm.MenuId.Value : 0
            };


            var localRoleData = roleData.ToList();
            var returned      = GetTreeStructurePages(localRoleData);

            return(returned);
        }
Ejemplo n.º 17
0
        /// <summary>
        /// Blue background visibility based on company type.
        /// </summary>
        /// <param name="type">Company type</param>
        /// <returns>Returns bool.</returns>
        private bool isBlue(CompanyTypeEnum type)
        {
            switch (type)
            {
            case CompanyTypeEnum.Retailer:
                return(false);

            case CompanyTypeEnum.OffRoad:
                return(true);

            case CompanyTypeEnum.Dealership:
                return(false);

            default:
                return(false);
            }
        }
Ejemplo n.º 18
0
        /// <summary>
        /// Gets the path of company type icon.
        /// </summary>
        /// <param name="type">Company type enum.</param>
        /// <returns>string path of company type.</returns>
        private string getCompanyTypeIcon(CompanyTypeEnum type)
        {
            switch (type)
            {
            case CompanyTypeEnum.Retailer:
                return(CommonImageSource.GetCompanyTypeIcon(CompanyTypeEnum.Retailer));

            case CompanyTypeEnum.OffRoad:
                return(CommonImageSource.GetCompanyTypeIcon(CompanyTypeEnum.OffRoad));

            case CompanyTypeEnum.Dealership:
                return(CommonImageSource.GetCompanyTypeIcon(CompanyTypeEnum.Dealership));

            default:
                return(string.Empty);
            }
        }
Ejemplo n.º 19
0
        /// <summary>
        /// 按行政级别获取可分配菜单对象
        /// </summary>
        /// <param name="comType"></param>
        /// <returns></returns>
        public IList <Function> GetFunctionByLevel(CompanyTypeEnum comType)
        {
            string strSql = "select * from function where Instr(FunctionLevel,'{0}') <> 0  "
                            + " and substr(functioncode,0,2)<>20  order by functioncode";

            strSql = string.Format(strSql, ((int)comType).ToString());

            OracleDataReader dr       = OracleHelper.ExecuteReader(strSql);
            IList <Function> datalist = new List <Function>();

            while (dr.Read())
            {
                Function function = new Function();
                function.FunctionCode = dr["FunctionCode"].ToString();
                function.FunctionName = dr["FunctionName"].ToString();
                function.FunctionUrl  = dr["FunctionUrl"].ToString();
                //function.IsFristPage = dr["FirstPage"].ToString().Equals("1");
                function.OrderNo = int.Parse(dr["OrderNo"].ToString());
                datalist.Add(function);
            }
            dr.Close();
            return(datalist);
        }
        public List <CountrtyAdministrator> GetCountryAdmin(CompanyTypeEnum typeRequested)
        {
            var admins = DataContext.CountryAdmins.Select(d => d);

            if (typeRequested != CompanyTypeEnum.Both)
            {
                var companyTypeId = GetCompanyIdForType(typeRequested);
                admins = admins.Where(d => d.CompanyTypeId == companyTypeId);
            }

            var adminEntities = from ca in admins

                                select new CountrtyAdministrator
            {
                CountryAdministratorId = ca.CountryAdminId,
                Country = ca.COUNTRy.country_description,
                Name    = ca.Name,
                Email   = ca.EmailAddress
            };
            var returned = adminEntities.ToList();

            return(returned);
        }
Ejemplo n.º 21
0
        public ActionResult Houses(int countryID, PagingParam pagingParam)
        {
            pagingParam = pagingParam ?? new PagingParam();

            var country = countryRepository.GetById(countryID);

            if (country == null)
            {
                return(RedirectToHomeWithError("Country does not exist!"));
            }


            int[] availableProducts = { (int)ProductTypeEnum.House };

            CompanyTypeEnum[]             companies = new CompanyTypeEnum[] { CompanyTypeEnum.Construction };
            IQueryable <MarketOfferModel> offers    = marketOfferRepository.GetAvailableOffers((int)ProductTypeEnum.House, 1, country, companies, availableProducts);

            if (SessionHelper.CurrentEntity.Is(EntityTypeEnum.Citizen))
            {
                offers = offers.Where(o => o.CompanyRegionID == SessionHelper.LoggedCitizen.RegionID);
            }

            if (offers.Count() > 0)
            {
                offers = offers.Apply(pagingParam);
            }

            var countries = countryRepository.GetAll().ToList();

            var vm = new CountryMarketOffersListViewModel(SessionHelper.CurrentEntity, country, offers.ToList(), countries, availableProducts, pagingParam, 1, (int)ProductTypeEnum.House);

            vm.DisableShowingQuantity();
            vm.QualityList = new List <SelectListItem>();

            return(View("MarketOffers", vm));
        }
Ejemplo n.º 22
0
        //public const int CorporateId = 1;

        public static int GetIdForCompanyType(CompanyTypeEnum typeRequested, MarsDBDataContext dataContext = null)
        {
            if (dataContext == null)
            {
                using (var dc = new MarsDBDataContext())
                {
                    var companyTypeId = dc.CompanyTypes.FirstOrDefault(d => d.CompanyTypeName == typeRequested.ToString());
                    if (companyTypeId == null)
                    {
                        throw new InvalidOperationException("Invalid CompanyType, change Enum CompanyTypeId to match Database table");
                    }
                    return(companyTypeId.CompanyTypeId);
                }
            }
            else
            {
                var companyTypeId = dataContext.CompanyTypes.FirstOrDefault(d => d.CompanyTypeName == typeRequested.ToString());
                if (companyTypeId == null)
                {
                    throw new InvalidOperationException("Invalid CompanyType, change Enum CompanyTypeId to match Database table");
                }
                return(companyTypeId.CompanyTypeId);
            }
        }
Ejemplo n.º 23
0
        /// <summary>
        /// 按行政级别获取可分配菜单对象
        /// </summary>
        /// <param name="comType"></param>
        /// <returns></returns>
        public IList<Function> GetFunctionByLevel(CompanyTypeEnum comType)
        {
            string strSql = "select * from function where Instr(FunctionLevel,'{0}') <> 0  "
              + " and substr(functioncode,0,2)<>20  order by functioncode";
            strSql = string.Format(strSql, ((int)comType).ToString());

            OracleDataReader dr = OracleHelper.ExecuteReader(strSql);
            IList<Function> datalist = new List<Function>();
            while (dr.Read())
            {
                Function function = new Function();
                function.FunctionCode = dr["FunctionCode"].ToString();
                function.FunctionName = dr["FunctionName"].ToString();
                function.FunctionUrl = dr["FunctionUrl"].ToString();
                //function.IsFristPage = dr["FirstPage"].ToString().Equals("1");
                function.OrderNo = int.Parse(dr["OrderNo"].ToString());
                datalist.Add(function);
            }
            dr.Close();
            return datalist;
        }
Ejemplo n.º 24
0
 public static bool CanSellProduct(CompanyTypeEnum companyType, ProductTypeEnum productType)
 {
     return(GetSellableProducts(companyType).Contains(productType));
 }
Ejemplo n.º 25
0
 public static bool Is(this Company company, CompanyTypeEnum companyType)
 {
     return(company.CompanyTypeID == (int)companyType);
 }
Ejemplo n.º 26
0
 public static int ToInt(this CompanyTypeEnum companyType)
 {
     return((int)companyType);
 }
Ejemplo n.º 27
0
        public static bool UpdateCompaniesWorkingWith(string userId, long[] companiesIds, CompanyTypeEnum type)
        {
            using (var context = new BackofficeUnitOfWork())
            {
                context.CompanyWorkingWith.Delete(i => i.ID_User == userId);

                if (null != companiesIds && companiesIds.Length > 0)
                {
                    var companyType = GetCompanyType(type);

                    int index = 0;
                    foreach (long companyId in companiesIds)
                    {
                        context.CompanyWorkingWith.Create(new CompanyWorkingWith()
                        {
                            ID_User        = userId,
                            Active         = true,
                            ID_Company     = companyId,
                            ID_CompanyType = companyType.ID,
                            Order          = index,
                            CreateDate     = DateTime.Now,
                            LastChangeDate = DateTime.Now
                        });
                        ++index;
                    }
                }

                context.Save();

                return(true);
            }
        }