public int Update(AvailableAppointmentTimeDTO dto)
        {
            var entity = ModelMapper.Mapper.Map <AvailableAppointmentTime>(dto);

            entity.EntityState = EntityState.Modified;
            return(_availableAppointmentRepository.Save(entity));
        }
Example #2
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));
        }
Example #3
0
 public int Update(AvailableAppointmentTimeDTO dto)
 {
     return(_availableAppointmentRepository.Update(dto));
 }