示例#1
0
        private TimesheetWeekDTO GetTimesheetData(Guid timeSheetId)
        {
            TimesheetWeekDTO val = null;

            using (HttpClientWrapper httpClient = new HttpClientWrapper(Session))
            {
                Task <String> response = httpClient.GetStringAsync("api/TimesheetAPI/" + timeSheetId.ToString());
                val = Task.Factory.StartNew(() => JsonConvert.DeserializeObject <TimesheetWeekDTO>(response.Result)).Result;

                using (var bc = new BusinessController())
                {
                    var businessDTO = bc.GetBusiness(val.BusinessId, this.Session);
                    ViewBag.BusinessId                 = val.BusinessId;
                    ViewBag.HasInternalLocations       = businessDTO.HasMultiInternalLocations;
                    ViewBag.SelectedBusinessName       = businessDTO.Name;
                    ViewBag.SelectedBusinessLocationId = val.BusinessLocationId;

                    if (businessDTO.HasMultiInternalLocations)
                    {
                        ViewBag.BusinessLocations = new SelectList(businessDTO.BusinessLocations, "Id", "Name", ViewBag.SelectedBusinessLocationId);
                    }
                }

                //using (var ec = new EmployerController())
                //{
                //    var employers = ec.GetEmployerSummary(this.Session);
                //    ViewBag.Businesses = new SelectList(employers.Employers, "BusinessId", "BusinessName", ViewBag.BusinessId);
                //}
            }
            return(val);
        }
示例#2
0
        //
        // GET: /Business/InternalLocationIndex/5
        public ActionResult RecurringShiftIndex(Guid businesslocationid)
        {
            using (BusinessController bc = new BusinessController())
            {
                var         busLocDTO   = bc.GetBusinessLocation(businesslocationid, this.Session);
                BusinessDTO businessDTO = bc.GetBusiness(busLocDTO.BusinessId, this.Session);
                ViewBag.HasInternalLocations = businessDTO.HasMultiInternalLocations;
                ViewBag.BusinessLocationId   = businesslocationid;
                ViewBag.BusinessId           = busLocDTO.BusinessId;
            }

            using (HttpClientWrapper httpClient = new HttpClientWrapper(Session))
            {
                Task <String> response       = httpClient.GetStringAsync("api/ShiftTemplateAPI?businesslocationid=" + businesslocationid.ToString());
                var           shiftTemplates = Task.Factory.StartNew(() => JsonConvert.DeserializeObject <IEnumerable <ShiftTemplateDTO> >(response.Result)).Result;

                return(PartialView(shiftTemplates));
            }
        }
示例#3
0
        //
        // GET: /Employee/Create
        public ActionResult Create(Guid?businessLocationId, Guid businessId, bool addedAnother = false)
        {
            ViewBag.AddedAnother = addedAnother;

            //Get roles for business
            using (BusinessController bc = new BusinessController())
            {
                bc.GetBusinessRoles(businessId, this.Session);
                BusinessDTO businessDTO = bc.GetBusiness(businessId, this.Session);
                ViewBag.BusinessRoles        = businessDTO.EnabledRoles;
                ViewBag.SelectedBusinessName = businessDTO.Name;

                if (!businessLocationId.HasValue)
                {
                    var enabledBusinessLocations = businessDTO.BusinessLocations.Where(e => e.Enabled);
                    //Ensure the business only has one location then set to this, otherwise throw an exception
                    if (enabledBusinessLocations.Count() == 1)
                    {
                        ViewBag.SelectedBusinessLocationId = enabledBusinessLocations.First().Id;
                    }
                    else
                    {
                        throw new Exception("Business location must be specified.");
                    }
                }
                else
                {
                    ViewBag.SelectedBusinessLocationId = businessLocationId.Value;
                }

                ViewBag.BusinessLocations = new SelectList(businessDTO.BusinessLocations, "Id", "Name", ViewBag.SelectedBusinessLocationId);
                // ViewBag.HasInternalLocations = businessDTO.HasMultiInternalLocations;
            }

            return(PartialView(new EmployeeDTO {
                BusinessId = businessId, BusinessLocationId = (Guid)ViewBag.SelectedBusinessLocationId, IsActive = true
            }));
        }
示例#4
0
        //
        // GET: /Business/InternalLocationCreate
        public ActionResult RecurringShiftCreate(Guid businessLocationId, Guid businessId)
        {
            ViewBag.BusinessLocationId = businessLocationId;

            //Get roles for business
            using (BusinessController bc = new BusinessController())
            {
                bc.GetBusinessRoles(businessId, this.Session);
                BusinessDTO businessDTO = bc.GetBusiness(businessId, this.Session);
                ViewBag.BusinessRoles     = businessDTO.EnabledRoles;
                ViewBag.BusinessId        = businessId;
                ViewBag.BusinessLocations = new SelectList(businessDTO.BusinessLocations, "Id", "Name", ViewBag.BusinessLocationId);

                var busLocDTO = businessDTO.BusinessLocations.FirstOrDefault(b => b.Id == businessLocationId);
                ViewBag.HasInternalLocations      = businessDTO.HasMultiInternalLocations;
                ViewBag.BusinessInternalLocations = busLocDTO.GetEnabledInternalLocations();
            }

            using (EmployeeController empController = new EmployeeController())
                ViewBag.BusinessEmployees = empController.GetEmployeesList(businessLocationId, Session);

            return(PartialView());
        }