public HttpResponseMessage Post(GeographicExpertiseApiModel newModel) { if ( (newModel == null) || (newModel.Locations == null) || (newModel.Locations.Count == 0) ) { return Request.CreateResponse(HttpStatusCode.InternalServerError); } var newLocations = new Collection<int>(); foreach (var location in newModel.Locations) { newLocations.Add(location.PlaceId); } var createDeepGeographicExpertiseCommand = new CreateDeepGeographicExpertise(User, newLocations) { Description = newModel.Description }; _createDeepGeographicExpertise.Handle(createDeepGeographicExpertiseCommand); var id = createDeepGeographicExpertiseCommand.CreatedGeographicExpertise.RevisionId; return Request.CreateResponse(HttpStatusCode.OK, id); }
public HttpResponseMessage Put(int expertiseId, GeographicExpertiseApiModel model) { if ((expertiseId == 0) || (model == null)) { return Request.CreateResponse(HttpStatusCode.InternalServerError); } try { var updateGeographicExpertiseCommand = Mapper.Map<UpdateGeographicExpertise>(model); updateGeographicExpertiseCommand.UpdatedOn = DateTime.UtcNow; updateGeographicExpertiseCommand.Principal = User; _updateGeographicExpertise.Handle(updateGeographicExpertiseCommand); } catch (Exception ex) { var responseMessage = new HttpResponseMessage { StatusCode = HttpStatusCode.NotModified, Content = new StringContent(ex.Message), ReasonPhrase = "GeographicExpertise update error" }; throw new HttpResponseException(responseMessage); } return Request.CreateResponse(HttpStatusCode.OK); }