public List <RestaurantModel> GetRestaurants(DateTime date) { var restaurants = _restaurantData.GetAll(); restaurants.ForEach(x => x.IsAvailable = _storyBusiness.CheckRestaurant(x.Id, date)); return(restaurants); }
public ReturnModel SubmitVote(VoteModel vote) { bool activeLimitTimeVote = Convert.ToBoolean(_configuration["LimitTime:Active"]); if (activeLimitTimeVote) { bool timesUp = LimitTimeVote(vote); if (timesUp) { return(new ReturnModel() { Success = false, Message = "Fora do horário de votação" }); } } if (!_userDate.Exists(vote.IdUser) || !_restaurantData.Exists(vote.IdRestaurant)) { return(new ReturnModel() { Success = false, Message = "Usuário ou restaurante não encontrado" }); } bool userValid = _storyBusiness.CheckUser(vote.IdUser, vote.DateVote); bool restaurantValid = _storyBusiness.CheckRestaurant(vote.IdRestaurant, vote.DateVote); if (userValid && restaurantValid) { _votationData.SubmitVote(vote); return(new ReturnModel() { Success = true, Message = "Voto realizado com sucesso" }); } return(new ReturnModel() { Success = false, Message = userValid ? "Restaurante já selecionado está semana" : "Você já votou" }); }