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)); }
//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); }