Exemple #1
0
        public async override Task <AppointmentView> Execute(UpdateAppointmentCommand input, User?user)
        {
            var appointment = await service.GetById(input.Id);

            if (!appointment.IsOwner(user !))
            {
                throw new AuthorizationException();
            }

            var update = new AppointmentUpdate(
                input.ServiceId,
                input.ClientId,
                input.Price,
                input.Notes
                );

            update.Blocks = input.Blocks.Select(b => new AppointmentBlockUpdate(
                                                    b.Start,
                                                    b.Start
                                                    )).ToList();

            await service.Update(appointment, update);

            throw new NotImplementedException();
            // return mapper.Map<Appointment, AppointmentView>(appointment);
        }
        public IHttpActionResult UpdateAppointment(AppointmentUpdate appointment)
        {
            var result = _appointmentService.UpdateAppointment(appointment);

            switch (result.Outcome)
            {
            case OperationUpdateResult.AppointmentOperation.AppointmentDoesNotExist:
                return(NotFound());

            case OperationUpdateResult.AppointmentOperation.CenterDoesNotExist:
                return(BadRequest(ErrorMsgCenterDoesNotExist));

            case OperationUpdateResult.AppointmentOperation.CenterAccommodationFull:
                return(Content(HttpStatusCode.Conflict, appointment));

            case OperationUpdateResult.AppointmentOperation.AppointmentUpdated:
                return(StatusCode(HttpStatusCode.NoContent));

            default:
                throw new ArgumentOutOfRangeException();
            }
        }