예제 #1
0
        public HomeSummaryDTO GetSites()
        {
            HomeSummaryDTO model = new HomeSummaryDTO();
            var            email = HttpContext.Current.User.Identity.Name;

            var employee = db.Employees.FirstOrDefault(x => x.Email == email);

            if (employee != null)
            {
                model.SiteSearch = new List <DropDownDTO>();
                //if user is a manager then he can find all the businesses, Employee of there own business and can get all the external users
                if (ClaimsAuthorization.CheckAccess("Put", "BusinessLocationId", employee.BusinessLocation.Id.ToString()))
                {
                    //Get the exernal users which are registered for get the ExternalBroadCast Shift.
                    model.SiteSearch = db.UserProfiles.Where(x => x.Email != email && x.IsRegisteredExternal == true).Select(a => new DropDownDTO
                    {
                        Text      = a.FirstName.ToLower() + " " + a.LastName.ToLower(),
                        ValueGuid = a.Id
                    }).ToList();
                }

                //if user is an employee then he can find his co-employee and all the business
                var BusinessLocationIds = (from e in db.Employees
                                           where e.Email == email
                                           select e.BusinessLocation.Id).ToList();
                foreach (var businesslocationid in BusinessLocationIds)
                {
                    var emps = db.Employees.Where(a => a.BusinessLocation.Id == businesslocationid && a.Email != email && a.UserProfile.Id != null).Select(y => new DropDownDTO {
                        Text = y.FirstName.ToLower() + " " + y.LastName.ToLower(), ValueGuid = y.Id
                    }).ToList();
                    foreach (var emp in emps)
                    {
                        model.SiteSearch.Add(emp);
                    }
                }

                //get all businesses
                var business = db.Businesses.Select(a => new DropDownDTO {
                    Text = a.Name.ToLower(), ValueGuid = a.Id
                }).ToList();
                foreach (var item in business)
                {
                    model.SiteSearch.Add(item);
                }
            }
            //if user is a Externaluser then he can only find the all Businesses
            else
            {
                model.SiteSearch = db.Businesses.Select(a => new DropDownDTO
                {
                    Text      = a.Name.ToLower(),
                    ValueGuid = a.Id
                }).ToList();
            }
            return(model);
        }
예제 #2
0
        public ActionResult NavMenu()
        {
            HomeSummaryDTO summary = null;

            //Get a summary of the employes currently linked to the Employee
            using (HttpClientWrapper httpClient = new HttpClientWrapper(Session))
            {
                Task <String> response = httpClient.GetStringAsync("api/SummaryAPI");
                summary = Task.Factory.StartNew(() => JsonConvert.DeserializeObject <HomeSummaryDTO>(response.Result)).Result;
            }
            return(PartialView(summary));
        }
예제 #3
0
        public ActionResult GetSiteSearch(string Prefix)
        {
            HomeSummaryDTO model = new HomeSummaryDTO();

            using (HttpClientWrapper httpclient = new HttpClientWrapper(Session))
            {
                var response = httpclient.GetAsync("api/SummaryAPI/GetSites").Result;
                model = JsonConvert.DeserializeObject <HomeSummaryDTO>(response.Content.ReadAsStringAsync().Result);
            }

            var SiteSearchResult = (from m in model.SiteSearch
                                    where m.Text.Contains(Prefix.ToLower())
                                    select m).ToList();

            return(Json(SiteSearchResult, JsonRequestBehavior.AllowGet));
        }
예제 #4
0
        public ActionResult AuthIndex()
        {
            ViewBag.Message = "You are currently logged into Rooster";
            //Get summary data
            HomeSummaryDTO summary = null;

            //Get a summary of the employes currently linked to the Employee
            using (HttpClientWrapper httpClient = new HttpClientWrapper(Session))
            {
                Task <String> response = httpClient.GetStringAsync("api/SummaryAPI");
                summary = Task.Factory.StartNew(() => JsonConvert.DeserializeObject <HomeSummaryDTO>(response.Result)).Result;

                var viewedWizardResponsed = httpClient.GetAsync("api/UserProfileAPI/GetHasViewedTutorial").Result;
                var viewedWizard          = JsonConvert.DeserializeObject <bool>(viewedWizardResponsed.Content.ReadAsStringAsync().Result);

                summary.HasViewedWizard = viewedWizard;
            }

            return(View(summary));
        }
예제 #5
0
        public ActionResult GetSearchType(Guid id)
        {
            HomeSummaryDTO model      = new HomeSummaryDTO();
            var            IsBusiness = string.Empty;

            using (HttpClientWrapper httpclient = new HttpClientWrapper(Session))
            {
                HttpResponseMessage response = httpclient.GetAsync("api/SummaryAPI/IsBusiness?id=" + id).Result;
                Response.StatusCode = (int)response.StatusCode;
                if (!response.IsSuccessStatusCode)
                {
                    return(this.Content(JsonConvert.DeserializeObject <dynamic>(response.Content.ReadAsStringAsync().Result).Message.ToString()));
                }
                else
                {
                    IsBusiness = response.Content.ReadAsStringAsync().Result;
                }
            }
            return(Json(IsBusiness, JsonRequestBehavior.AllowGet));
        }
예제 #6
0
        public HomeSummaryDTO GetSummary()
        {
            HomeSummaryDTO empSummary = new HomeSummaryDTO();
            var            email      = HttpContext.Current.User.Identity.Name;
            DateTime       now        = WebUI.Common.Common.DateTimeNowLocal();

            //Get list of businesses which user is a manager of
            var mgrBusIdList = GetManagerList(email);

            //Get list of businesses which user is an employee of
            var empBusIdList = from emp in db.Employees
                               where emp.UserProfile.Email == email
                               select emp.BusinessLocation.Id;

            var upcomingShiftList = from s in db.Shifts
                                    where s.IsPublished == true &&
                                    s.Employee.UserProfile.Email == email &&
                                    s.StartTime > now &&
                                    DbFunctions.DiffHours(now, s.StartTime) < 168    //168 hours is 7 days
                                    select new
            {
                Id = s.Id,
                BusinessLocationId   = s.Roster.BusinessLocation.Id,
                StartDate            = s.StartTime,
                FinishDate           = s.FinishTime,
                BusinessLocationName = s.Roster.BusinessLocation.Name,
                Role = s.Role.Name
            };

            var busSummaryList = from busLoc in db.BusinessLocations
                                 join emp in db.Employees on busLoc.Id equals emp.BusinessLocation.Id
                                 join usr in db.UserProfiles on emp.UserProfile.Id equals usr.Id
                                 where usr.Email == email
                                 select new BusinessLocationSummaryDTO {
                BusinessId = busLoc.Business.Id, BusinessName = busLoc.Business.Name, Id = busLoc.Id, Name = busLoc.Name, HasInternalLocations = busLoc.Business.HasMultiInternalLocations, UserIsAdmin = mgrBusIdList.Contains(busLoc.Id)
            };

            var busProfileAddress = from User in db.UserProfiles
                                    where User.Email == email
                                    select new UserProfilesDTO
            {
                Line1          = User.CurrentAddress.Line1,
                Suburb         = User.CurrentAddress.Suburb,
                Line2          = User.CurrentAddress.Line2,
                State          = User.CurrentAddress.State,
                Postcode       = User.CurrentAddress.Postcode,
                PlaceLongitude = User.CurrentAddress.PlaceLongitude,
                PlaceLatitude  = User.CurrentAddress.PlaceLatitude,
                PlaceId        = User.CurrentAddress.PlaceId,
                Distance       = User.Distance,
                IndustryTypeId = User.IndustryTypesID
            };

            using (var ExternalBroadcastAPI = new ExternalBroadcastAPIController())
            {
                empSummary.ExternalShiftBroadCastEmpoyee = ExternalBroadcastAPI.GetEmployeeExternalShift();
            }

            empSummary.Employers = busSummaryList.Distinct().ToList();

            empSummary.UpcomingShifts = upcomingShiftList.OrderBy(s => s.StartDate);

            empSummary.IndustryType = db.IndustryTypes.Select(x => new DropDownDTO
            {
                Value = x.ID,
                Text  = x.Name
            }).ToList();

            //empSummary.IndustryType = db.IndustryTypes.GroupBy(g => g.Industry).Select(x => new BusinessTypeDTO { Id = x.Select(s => s.Id).FirstOrDefault(), Industry = x.Key }).Distinct().ToList();

            empSummary.Address = busProfileAddress.FirstOrDefault();

            // Temporary List of data for Distance Dropdown.
            List <DropDownDTO> DistanceListStatic = new List <DropDownDTO>();

            DistanceListStatic.Add(new DropDownDTO {
                Value = 1, Text = "1 Kms"
            });
            DistanceListStatic.Add(new DropDownDTO {
                Value = 5, Text = "5 Kms"
            });
            DistanceListStatic.Add(new DropDownDTO {
                Value = 10, Text = "10 Kms"
            });
            DistanceListStatic.Add(new DropDownDTO {
                Value = 20, Text = "20 Kms"
            });

            empSummary.LocationRange = DistanceListStatic;

            using (var shiftApiController = new ShiftAPIController())
            {
                empSummary.OpenShiftsEmployee = shiftApiController.GetOpenShiftsForCurrentUser();
            }

            return(empSummary);
        }