コード例 #1
0
        public ActionResult AddFormation(CreateFormationRequest createRequest)
        {
            if (_validator.Validate(createRequest))
            {
                return(BadRequest("All formation information must be filled out."));
            }

            var newFormation = _repository.AddFormation(createRequest.FormationName, createRequest.Location, createRequest.Formed, createRequest.Latitude, createRequest.Longitude, createRequest.Fossil);

            return(Created($"api/formation/{newFormation.Id}", newFormation));
        }
コード例 #2
0
 public bool Validate(CreateFormationRequest requestToValidate)
 {
     return(string.IsNullOrEmpty(requestToValidate.FormationName) ||
            string.IsNullOrEmpty(requestToValidate.Location));
 }