コード例 #1
0
        public IHttpActionResult UpdateUnavailablePeriod(int id, DateTimeModel model)
        {
            if (!ModelState.IsValid)
            {
                return(InternalServerError(new Exception("Invalid model state")));
            }

            BusySchedules updatedWorkTime;

            try
            {
                Users currentUser = GetUser();
                updatedWorkTime = ScheduleService.UpdateBusyInterval(
                    currentUser.Id,
                    id,
                    model.GetStartDateTime(),
                    model.GetEndDateTime());
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }

            return(Ok(updatedWorkTime));
        }
コード例 #2
0
        public IHttpActionResult GetUnvailablePeriods(int userId, [FromUri] DateTimeModel model)
        {
            if (!ModelState.IsValid)
            {
                return(InternalServerError(new Exception("Invalid model state")));
            }

            List <BusySchedules> existingUnvailablePeriods;

            try
            {
                existingUnvailablePeriods = ScheduleService.GetAllBusyIntervalsPerPeriod(
                    userId, model.GetStartDateTime(), model.GetEndDateTime());
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }

            return(Ok(existingUnvailablePeriods));
        }
コード例 #3
0
        public IHttpActionResult AddUnavailablePeriod(DateTimeModel model)
        {
            if (!ModelState.IsValid)
            {
                return(InternalServerError(new Exception("Invalid model state")));
            }

            BusySchedules newUnavailablePeriod;

            try
            {
                Users currentUser = GetUser();
                newUnavailablePeriod = ScheduleService.AddBusyInterval(
                    currentUser.Id, model.GetStartDateTime(), model.GetEndDateTime());
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }

            return(Ok(newUnavailablePeriod));
        }