public HttpResponseMessage GetTimeSlotByDate(JobTimeSlotsQueryRequest model)
        {
            if (!ModelState.IsValid)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState));
            }

            ItemsResponse <JobTimeSlots> response = new ItemsResponse <JobTimeSlots>();

            response.Items = _ScheduleService.GetAllTimeSlotByDate(model);

            return(Request.CreateResponse(HttpStatusCode.OK, response));
        }
        public HttpResponseMessage GetByTeamId(int TeamId, JobTimeSlotsQueryRequest model)
        {
            if (!ModelState.IsValid)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState));
            }

            TimeSlotsItemsResponse <JobTimeSlots> response = new TimeSlotsItemsResponse <JobTimeSlots>();

            response = _ScheduleService.GetAllTimeSlotsByTeam(WebsiteId, model);

            return(Request.CreateResponse(HttpStatusCode.OK, response));
        }
Exemplo n.º 3
0
        //This API grabs all available slots, then filters out the defaults that have overrides.  Then grabs capacity.
        public List <JobTimeSlots> GetAllAvailableByDate(JobTimeSlotsQueryRequest model)
        {
            List <JobTimeSlots> TimeSlotList = new List <JobTimeSlots>();

            DataProvider.ExecuteCmd(GetConnection, "dbo.JobTimeSlots_SelectAvailableByDate"
                                    , inputParamMapper : delegate(SqlParameterCollection paramCollection)
            {
                paramCollection.AddWithValue("@TeamId", model.TeamId);
                paramCollection.AddWithValue("@QueryDate", model.QueryDate);
                paramCollection.AddWithValue("@QueryDay", model.QueryDay);
            }, map : delegate(IDataReader reader, short set)
            {
                JobTimeSlots c    = new JobTimeSlots();
                int startingIndex = 0;

                c.Id           = reader.GetSafeInt32(startingIndex++);
                c.Date         = reader.GetSafeDateTimeNullable(startingIndex++);
                c.CreatedDate  = reader.GetSafeDateTime(startingIndex++);
                c.ModifiedDate = reader.GetSafeDateTime(startingIndex++);
                c.TimeStart    = reader.GetSafeInt32(startingIndex++);
                c.TimeEnd      = reader.GetSafeInt32(startingIndex++);
                c.Capacity     = reader.GetSafeInt32(startingIndex++);
                c.DefaultId    = reader.GetSafeInt32Nullable(startingIndex++);
                c.DayOfWeek    = reader.GetSafeString(startingIndex++);
                c.TeamId       = reader.GetSafeInt32(startingIndex++);
                c.ScheduleType = reader.GetSafeBool(startingIndex++);

                TimeSlotList.Add(c);
            });

            //Replace the Defaults with Overrides that exist
            for (int i = 0; i < TimeSlotList.Count; i++)
            {
                if (TimeSlotList[i].DefaultId != null)
                {
                    for (int x = 0; x < TimeSlotList.Count; x++)
                    {
                        if (TimeSlotList[x].Id == TimeSlotList[i].DefaultId)
                        {
                            TimeSlotList.RemoveAt(x);
                        }
                    }
                }
            }

            //Grab Availabilities By Date
            List <JobCountUsed> Availabilities = new List <JobCountUsed>();

            Availabilities = GetCapacityByQuery(model.QueryDate);

            //Grab Capacity Used From Data Received From Service
            for (int i = 0; i < TimeSlotList.Count; i++)
            {
                int currentUsed = 0;

                for (int y = 0; y < Availabilities.Count; y++)
                {
                    if (TimeSlotList[i].Id == Availabilities[y].ScheduleId)
                    {
                        currentUsed = Availabilities[y].CurrentUsed;
                    }
                }

                TimeSlotList[i].UsedCapacity = currentUsed;
            }

            return(TimeSlotList);
        }
Exemplo n.º 4
0
        //Grab Time Slots By Date for default or override.  Then checks to see if a ASAP slot exists for the day and adds one.  Hangfire backup still required.
        public List <JobTimeSlots> GetAllTimeSlotByDate(JobTimeSlotsQueryRequest model)
        {
            List <JobTimeSlots> TimeSlotList = new List <JobTimeSlots>();

            DataProvider.ExecuteCmd(GetConnection, "dbo.JobTimeSlots_SelectByDate"
                                    , inputParamMapper : delegate(SqlParameterCollection paramCollection)
            {
                paramCollection.AddWithValue("@TeamId", model.TeamId);
                paramCollection.AddWithValue("@ScheduleType", model.ScheduleType);
                paramCollection.AddWithValue("@QueryDate", model.QueryDate);
                paramCollection.AddWithValue("@QueryDay", model.QueryDay);
            }, map : delegate(IDataReader reader, short set)
            {
                JobTimeSlots c    = new JobTimeSlots();
                int startingIndex = 0;

                c.Id           = reader.GetSafeInt32(startingIndex++);
                c.Date         = reader.GetSafeDateTimeNullable(startingIndex++);
                c.CreatedDate  = reader.GetSafeDateTime(startingIndex++);
                c.ModifiedDate = reader.GetSafeDateTime(startingIndex++);
                c.TimeStart    = reader.GetSafeInt32(startingIndex++);
                c.TimeEnd      = reader.GetSafeInt32(startingIndex++);
                c.Capacity     = reader.GetSafeInt32(startingIndex++);
                c.DefaultId    = reader.GetSafeInt32Nullable(startingIndex++);
                c.DayOfWeek    = reader.GetSafeString(startingIndex++);
                c.TeamId       = reader.GetSafeInt32(startingIndex++);
                c.ScheduleType = reader.GetSafeBool(startingIndex++);

                TimeSlotList.Add(c);
            });

            //Checking to see if a ASAP Time Slot exists for ASAP, and then adds one based on if it does or not
            if (TimeSlotList.Count == 0 && model.ScheduleType == false)
            {
                int AsapTimeSlotId = 0;

                JobTimeSlots AsapTimeSlot = new JobTimeSlots();
                AsapTimeSlot.Date         = getTodayDate();
                AsapTimeSlot.TimeStart    = 0;
                AsapTimeSlot.TimeEnd      = 2400;
                AsapTimeSlot.Capacity     = 1;
                AsapTimeSlot.DefaultId    = null;
                AsapTimeSlot.DayOfWeek    = (getTodayDate()).ToString("dddd");
                AsapTimeSlot.TeamId       = model.TeamId;
                AsapTimeSlot.ScheduleType = false;

                AsapTimeSlotId = InsertNewTimeSlot(AsapTimeSlot);

                if (AsapTimeSlotId > 0)
                {
                    List <JobTimeSlots> AsapTimeSlotList = new List <JobTimeSlots>();

                    AsapTimeSlotList = GetAllTimeSlotByDate(model);

                    return(AsapTimeSlotList);
                }
            }


            return(TimeSlotList);
        }
Exemplo n.º 5
0
        //Triple Select for grabbing ALL Types of Time Slots (Default, Override, ASAP)
        public TimeSlotsItemsResponse <JobTimeSlots> GetAllTimeSlotsByTeam(int TeamId, JobTimeSlotsQueryRequest model)
        {
            List <JobTimeSlots> TimeSlotList         = new List <JobTimeSlots>();
            List <JobTimeSlots> OverrideTimeSlotList = new List <JobTimeSlots>();
            List <JobTimeSlots> AsapTimeSlotList     = new List <JobTimeSlots>();

            DataProvider.ExecuteCmd(GetConnection, "dbo.JobTimeSlots_SelectAllByTeamId"
                                    , inputParamMapper : delegate(SqlParameterCollection paramCollection)
            {
                paramCollection.AddWithValue("@TeamId", TeamId);
                paramCollection.AddWithValue("@QueryDay", model.QueryDay);
            }, map : delegate(IDataReader reader, short set)
            {
                if (set == 0)
                {
                    JobTimeSlots c    = new JobTimeSlots();
                    int startingIndex = 0;

                    c.Id           = reader.GetSafeInt32(startingIndex++);
                    c.Date         = reader.GetSafeDateTimeNullable(startingIndex++);
                    c.CreatedDate  = reader.GetSafeDateTime(startingIndex++);
                    c.ModifiedDate = reader.GetSafeDateTime(startingIndex++);
                    c.TimeStart    = reader.GetSafeInt32(startingIndex++);
                    c.TimeEnd      = reader.GetSafeInt32(startingIndex++);
                    c.Capacity     = reader.GetSafeInt32(startingIndex++);
                    c.DefaultId    = reader.GetSafeInt32Nullable(startingIndex++);
                    c.DayOfWeek    = reader.GetSafeString(startingIndex++);
                    c.TeamId       = reader.GetSafeInt32(startingIndex++);
                    c.ScheduleType = reader.GetSafeBool(startingIndex++);

                    TimeSlotList.Add(c);
                }
                else if (set == 1)
                {
                    JobTimeSlots d    = new JobTimeSlots();
                    int startingIndex = 0;

                    d.Id           = reader.GetSafeInt32(startingIndex++);
                    d.Date         = reader.GetSafeDateTimeNullable(startingIndex++);
                    d.CreatedDate  = reader.GetSafeDateTime(startingIndex++);
                    d.ModifiedDate = reader.GetSafeDateTime(startingIndex++);
                    d.TimeStart    = reader.GetSafeInt32(startingIndex++);
                    d.TimeEnd      = reader.GetSafeInt32(startingIndex++);
                    d.Capacity     = reader.GetSafeInt32(startingIndex++);
                    d.DefaultId    = reader.GetSafeInt32Nullable(startingIndex++);
                    d.DayOfWeek    = reader.GetSafeString(startingIndex++);
                    d.TeamId       = reader.GetSafeInt32(startingIndex++);
                    d.ScheduleType = reader.GetSafeBool(startingIndex++);


                    OverrideTimeSlotList.Add(d);
                }
                else if (set == 2)
                {
                    JobTimeSlots e    = new JobTimeSlots();
                    int startingIndex = 0;

                    e.Id           = reader.GetSafeInt32(startingIndex++);
                    e.Date         = reader.GetSafeDateTimeNullable(startingIndex++);
                    e.CreatedDate  = reader.GetSafeDateTime(startingIndex++);
                    e.ModifiedDate = reader.GetSafeDateTime(startingIndex++);
                    e.TimeStart    = reader.GetSafeInt32(startingIndex++);
                    e.TimeEnd      = reader.GetSafeInt32(startingIndex++);
                    e.Capacity     = reader.GetSafeInt32(startingIndex++);
                    e.DefaultId    = reader.GetSafeInt32Nullable(startingIndex++);
                    e.DayOfWeek    = reader.GetSafeString(startingIndex++);
                    e.TeamId       = reader.GetSafeInt32(startingIndex++);
                    e.ScheduleType = reader.GetSafeBool(startingIndex++);


                    AsapTimeSlotList.Add(e);
                }
            });

            TimeSlotsItemsResponse <JobTimeSlots> response = new TimeSlotsItemsResponse <JobTimeSlots>();

            response.Items         = TimeSlotList;
            response.OverrideItems = OverrideTimeSlotList;
            response.AsapItems     = AsapTimeSlotList;

            return(response);
        }