public bool CreateAvaliation(UserAvaliationViewModel avaliation)
        {
            var service = _unitOfWork.ServiceSchedule.FirstOrDefault(s => s.ID == avaliation.ServiceScheduleID);

            if (service == null)
            {
                return(false);
            }

            service.Scored = true;
            _unitOfWork.ServiceSchedule.Edit(service);
            _unitOfWork.UserAvaliation.Add(new Data.Models.UserAvaliation()
            {
                ID                = Guid.NewGuid(),
                ClientID          = avaliation.ClientID,
                ServiceScheduleID = avaliation.ServiceScheduleID,
                Score             = avaliation.Score,
                Description       = avaliation.Description,
                Status            = true
            });

            try
            {
                _unitOfWork.Commit();
                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
        public ActionResult Avaliate(UserAvaliationViewModel model)
        {
            if (!ModelState.IsValid)
            {
                var serviceSchedule = _serviceScheduleService.GetServiceSchedule((Guid)model.ServiceScheduleID, model.Score, model.Description);
                if (serviceSchedule == null)
                {
                    SetSessionNotification("Não foi possível localizar o serviço.", "alert-danger");
                    return(RedirectToAction("Index"));
                }
                return(View(serviceSchedule));
            }

            var result = _serviceScheduleService.CreateAvaliation(model);

            if (result)
            {
                SetSessionNotification("Avaliação realizada com sucesso!", "alert-success");
                return(RedirectToAction("Index"));
            }
            else
            {
                SetSessionNotification("Não foi possível enviar a avaliação.", "alert-danger");
                return(RedirectToAction("Index"));
            }
        }
        public UserAvaliationViewModel GetServiceSchedule(Guid serviceScheduleID, int score, string description)
        {
            var schedule = _unitOfWork.ServiceSchedule.FirstOrDefault(s => s.ID == serviceScheduleID);

            if (schedule == null)
            {
                return(null);
            }

            var avaliation = new UserAvaliationViewModel()
            {
                ServiceScheduleID = schedule.ID,
                ClientID          = schedule.ClientID,
                ServiceName       = schedule.Service.Name,
                PetName           = schedule.Pet.Name,
                ResponsibleName   = schedule.Responsible.Name,
                Description       = description,
                Score             = score,
                ScheduleText      = String.Concat(schedule.Schedule.ToShortDateString(), " ", schedule.Schedule.ToShortTimeString())
            };

            return(avaliation);
        }