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)); }
public bool Validate(CreateFavoriteRequest requestToValidate) { return(string.IsNullOrEmpty(requestToValidate.UserId.ToString()) || string.IsNullOrEmpty(requestToValidate.FossilId.ToString()) || string.IsNullOrEmpty(requestToValidate.FormationId.ToString())); }