Example #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="_city"></param>
        /// <param name="BusinessTypeGuid"></param>
        /// <param name="LatestPage"></param>
        /// <returns></returns>
        public MyBusiness GetBusinessByCity(City _city, Nullable <Guid> BusinessTypeGuid, int LatestPage = 0)
        {
            MyBusiness _businessSearch = new MyBusiness();

            _businessSearch.PageSize    = PageSizeBusiness;
            _businessSearch.CurrentPage = LatestPage > 0 ? LatestPage : CurrentPage;
            _businessSearch.SortBy      = SortBy;

            if (BusinessTypeGuid == null || BusinessTypeGuid == Guid.Empty)
            {
                BusinessTypeGuid = Guid.Empty;
                BusinessTypeGuid = Guid.Parse("AB97A903-B8F3-4772-AAF8-4CDCEA630054");
            }

            _businessSearch.BusinessObjects = bringlyEntities.tblBranches
                                              .Where(x => x.IsDeleted == false && x.FK_BusinessTypeGuid == BusinessTypeGuid)
                                              .Select(r => new BusinessObject
            {
                BusinessImage = r.BranchImage,
                BusinessGuid  = r.BranchGuid,
                BusinessName  = r.BranchName,
                CityGuid      = r.FK_CityGuid,
                CityName      = _city.CityName,
                IsFavorite    = false,
                Address       = r.Address
            }).ToList();

            _businessSearch.BusinessName = bringlyEntities.tblBusinessTypes
                                           .Where(x => x.BusinessTypeGuid == BusinessTypeGuid.Value)
                                           .FirstOrDefault()
                                           .BusinessTypeName;

            if (_city.CityGuid != null)
            {
                _businessSearch.BusinessObjects = _businessSearch.BusinessObjects
                                                  .Where(s => s.CityGuid == _city.CityGuid)
                                                  .ToList();
            }
            if (_businessSearch.BusinessName.Trim().ToLower() == "restaurant")
            {
                _businessSearch.SaloonSlotList = GetAllSaloonSlots();
            }
            UserDomainLogic       userDomainLogic    = new UserDomainLogic();
            List <BusinessObject> favouriteLocations = userDomainLogic.FavouriteLocations();//favourite part left

            _businessSearch.CityGuid = _city.CityGuid;
            _businessSearch.CityName = _city.CityName;
            List <Guid> businessGuid = favouriteLocations.Select(c => c.BusinessGuid).ToList();//favourite part left

            foreach (BusinessObject busines in _businessSearch.BusinessObjects)
            {
                if (businessGuid.Contains(busines.BusinessGuid))
                {
                    busines.IsFavorite = true;
                }
            }
            _businessSearch.TotalRecords = _businessSearch.BusinessObjects.Count;
            int Skip = 0;
            int Take = PageSize;

            if (_businessSearch.CurrentPage == 1)
            {
                Skip = 0;
            }
            else
            {
                Skip = ((_businessSearch.CurrentPage * _businessSearch.PageSize) - _businessSearch.PageSize);
            }

            _businessSearch.BusinessObjects = _businessSearch.BusinessObjects.Skip(Skip).Take(Take).ToList();

            return(_businessSearch);
        }
Example #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="guid"></param>
        /// <param name="LatestPage"></param>
        /// <returns></returns>
        public MyBusiness GetAppointmentByUserGuid(Guid guid, int LatestPage = 0)
        {
            MyBusiness MyBusiness = new MyBusiness();

            MyBusiness.PageSize    = PageSize;
            MyBusiness.CurrentPage = LatestPage > 0 ? LatestPage : CurrentPage;; //ViewBag.CurrentPage
            MyBusiness.SortBy      = SortBy;
            if (guid != null && guid != Guid.Empty)
            {
                MyBusiness.BusinessObjects = bringlyEntities.tblSaloonAppointments
                                             .Where(x => x.SaloonAppointmentGuid == guid && x.IsDeleted == false && x.FK_UserGuid == UserVariables.LoggedInUserGuid)
                                             .Select(c => new BusinessObject
                {
                    SaloonAppointmentGuid = c.SaloonAppointmentGuid,
                    AppointmentDate       = c.AppointmentDate,
                    UserGuid         = c.FK_UserGuid,
                    IsApproved       = c.IsApproved,
                    BusinessGuid     = c.FK_BusinessGuid,
                    BusinessTypeGuid = bringlyEntities.tblBranches.Where(x => x.BranchGuid == c.FK_BusinessGuid).FirstOrDefault()
                                       .FK_BusinessTypeGuid,
                    SaloonTimeGuid = c.FK_SaloonTimeGuid,
                    SaloonTime     = c.SaloonTime,
                    BusinessName   = bringlyEntities.tblBranches.Where(z => z.BranchGuid == c.FK_BusinessGuid).FirstOrDefault().BranchName
                }).ToList();
            }
            else
            {
                MyBusiness.BusinessObjects = bringlyEntities.tblSaloonAppointments
                                             .Where(x => x.IsDeleted == false && x.FK_UserGuid == UserVariables.LoggedInUserGuid)
                                             .Select(c => new BusinessObject
                {
                    SaloonAppointmentGuid = c.SaloonAppointmentGuid,
                    AppointmentDate       = c.AppointmentDate,
                    UserGuid         = c.FK_UserGuid,
                    IsApproved       = c.IsApproved,
                    BusinessGuid     = c.FK_BusinessGuid,
                    SaloonTimeGuid   = c.FK_SaloonTimeGuid,
                    BusinessTypeGuid = bringlyEntities.tblBranches.Where(x => x.BranchGuid == c.FK_BusinessGuid).FirstOrDefault().FK_BusinessTypeGuid,
                    SaloonTime       = c.SaloonTime,
                    BusinessName     = bringlyEntities.tblBranches.Where(z => z.BranchGuid == c.FK_BusinessGuid).FirstOrDefault()
                                       .BranchName
                }).ToList();
            }

            MyBusiness.SaloonSlotList = GetAllSaloonSlots();
            MyBusiness.TotalRecords   = MyBusiness.BusinessObjects.Count;
            int Skip = 0;
            int Take = PageSize;

            if (MyBusiness.CurrentPage == 1)
            {
                Skip = 0;
            }
            else
            {
                Skip = ((MyBusiness.CurrentPage * MyBusiness.PageSize) - MyBusiness.PageSize);
            }

            MyBusiness.BusinessObjects = MyBusiness.BusinessObjects.Skip(Skip).Take(Take).ToList();

            return(MyBusiness);
        }
Example #3
0
 public HomeController(MyBusiness myBusiness, IHubContext <MyHub> hubContext)
 {
     _myBusiness = myBusiness;
     _hubContext = hubContext;
 }