Beispiel #1
0
        public ActionResult <ItemResponse <ScheduleAvailablityByDate> > GetAvailability(int userId, DateTime scheduleDate)
        {
            int          code     = 200;
            BaseResponse response = null;

            try
            {
                ScheduleAvailablityByDate availablity = _service.GetAvailability(userId, scheduleDate);

                if (availablity == null)
                {
                    code     = 404;
                    response = new ErrorResponse("No Availability found");
                }
                else
                {
                    response = new ItemResponse <ScheduleAvailablityByDate> {
                        Item = availablity
                    };
                }
            }
            catch (Exception ex)
            {
                code     = 500;
                response = new ErrorResponse(ex.Message);
            }
            return(StatusCode(code, response));
        }
Beispiel #2
0
        public ScheduleAvailablityByDate GetAvailability(int userId, DateTime scheduleDate)
        {
            string procName = "[dbo].[ScheduleAvailability_SelectByDate]";
            ScheduleAvailablityByDate schedule = null;

            _data.ExecuteCmd(procName, inputParamMapper : delegate(SqlParameterCollection col)
            {
                col.AddWithValue("@ProviderId", userId);
                col.AddWithValue("@Date", scheduleDate);
            }, singleRecordMapper : delegate(IDataReader reader, short set)
            {
                schedule          = new ScheduleAvailablityByDate();
                int startingIndex = 0;

                schedule.ProviderId           = reader.GetSafeInt32(startingIndex++);
                schedule.DayOfWeek            = reader.GetSafeInt32(startingIndex++);
                schedule.ScheduleAvailability = reader.DeserializeObject <List <ScheduleAvailabilityTime> >(startingIndex++);
                schedule.Appointments         = reader.DeserializeObject <List <AppointmentTime> >(startingIndex++);
            });
            return(schedule);
        }