Esempio n. 1
0
        public ActionResult AvailableAppointmentTimeCreate([FromForm] AvailableAppointmentTimeCO request)
        {
            var sonuc = new ResultDTO();

            if (request == null)
            {
                throw new PetClinicAppointmentBadRequestException("You have not sent any data!");
            }

            if (string.IsNullOrEmpty(request.Time.ToString()))
            {
                throw new PetClinicAppointmentBadRequestException("Time cannot be empty!");
            }

            if (string.IsNullOrEmpty(request.AppointmentTime.ToLongDateString()))
            {
                throw new PetClinicAppointmentBadRequestException("Pet appointment time cannot be empty!");
            }

            var dto = new AvailableAppointmentTimeDTO()
            {
                Guid            = Guid.NewGuid(),
                Deleted         = false,
                Actived         = true,
                CreatedDate     = DateTime.Now,
                AppointmentTime = request.AppointmentTime,
                Time            = request.Time
            };

            var durum = _availableAppointmentService.Create(dto);

            if (durum > 0)
            {
                sonuc.Status = EDurum.SUCCESS;
                sonuc.Message.Add(new MessageDTO()
                {
                    Code        = HttpStatusCode.OK,
                    Status      = EDurum.SUCCESS,
                    Description = "Available appointment time was created successfully."
                });
                sonuc.Data = new
                {
                    availableAppointmentTime = new
                    {
                        dto.Guid,
                        dto.AppointmentTime,
                        dto.Time
                    }
                };
            }
            else
            {
                throw new PetClinicAppointmentBadRequestException("Couldn't create an available appointment time!");
            }

            return(Ok(sonuc));
        }
Esempio n. 2
0
        public ActionResult AvailableAppointmentTimeUpdate(Guid availableAppointmentTimeGuid, [FromForm] AvailableAppointmentTimeCO request)
        {
            var sonuc = new ResultDTO();

            if (request == null)
            {
                throw new PetClinicAppointmentBadRequestException("You have not sent any data!");
            }

            if (availableAppointmentTimeGuid == default(Guid) || availableAppointmentTimeGuid == null)
            {
                throw new PetClinicAppointmentBadRequestException("Submit valid available appointment time information!");
            }

            var availableAppointmentTime = _availableAppointmentService.GetByGuid(availableAppointmentTimeGuid);

            if (availableAppointmentTime == null)
            {
                throw new PetClinicAppointmentNotFoundException("Available appointment time not found!");
            }

            if (string.IsNullOrEmpty(request.Time.ToString()))
            {
                throw new PetClinicAppointmentBadRequestException("Time cannot be empty!");
            }

            if (string.IsNullOrEmpty(request.AppointmentTime.ToLongDateString()))
            {
                throw new PetClinicAppointmentBadRequestException("Pet appointment time cannot be empty!");
            }

            availableAppointmentTime.AppointmentTime = request.AppointmentTime;
            availableAppointmentTime.Time            = request.Time;

            var durum = _availableAppointmentService.Update(availableAppointmentTime);

            if (durum > 0)
            {
                sonuc.Status = EDurum.SUCCESS;
                sonuc.Message.Add(new MessageDTO()
                {
                    Code        = HttpStatusCode.OK,
                    Status      = EDurum.SUCCESS,
                    Description = "The available appointment time has been successfully updated."
                });
                sonuc.Data = new { availableAppointmentTime = new { availableAppointmentTime.Guid } };
            }
            else
            {
                throw new PetClinicAppointmentBadRequestException("The available appointment time could not be updated!");
            }

            return(Ok(sonuc));
        }