Example #1
0
        public ActionResult AddFavorite(CreateFavoriteRequest createRequest)
        {
            if (_validator.Validate(createRequest))
            {
                return(BadRequest("All favorite information must be filled out."));
            }

            var newFavorite = _repository.AddFavorite(createRequest.UserId, createRequest.FossilId, createRequest.FormationId);

            return(Created($"api/favorite/{newFavorite.Id}", newFavorite));
        }
Example #2
0
 public bool Validate(CreateFavoriteRequest requestToValidate)
 {
     return(string.IsNullOrEmpty(requestToValidate.UserId.ToString()) ||
            string.IsNullOrEmpty(requestToValidate.FossilId.ToString()) ||
            string.IsNullOrEmpty(requestToValidate.FormationId.ToString()));
 }