Пример #1
0
        public IActionResult DeleteAppointemnt(int id)
        {
            Hairdresser hairdresser = _hairdresserRepository.GetByEmail(User.Identity.Name);

            if (hairdresser == null)
            {
                return(NotFound());
            }

            Appointment appointment = hairdresser.GetAppointment(id);

            hairdresser.RemoveAppointment(appointment);

            _hairdresserRepository.SaveChanges();

            return(NoContent());
        }
Пример #2
0
        public ActionResult <AppointmentDTO> GetAppointment(int id)
        {
            Hairdresser hairdresser = _hairdresserRepository.GetByEmail(User.Identity.Name);

            if (hairdresser == null)
            {
                return(NotFound());
            }

            Appointment appointment = hairdresser.GetAppointment(id);

            if (appointment == null)
            {
                return(NotFound());
            }

            return(Ok(new AppointmentDTO()
            {
                Id = appointment.Id, Firstname = appointment.Firstname, Lastname = appointment.Lastname, StartMoment = appointment.StartMoment, Treatments = appointment.Treatments.Select(tr => tr.Treatment).ToList()
            }));
        }