Example #1
0
        public HttpResponseMessage AddObservation(ObservationVm observationVm)
        {
            if (Request.Method == HttpMethod.Options)
            {
                return new HttpResponseMessage()
                       {
                           StatusCode = HttpStatusCode.OK
                       }
            }
            ;

            if (loggedUserId == null)
            {
                //TODO: you are not logged message here
                return(Request.CreateResponse(HttpStatusCode.Unauthorized, "err niezalogowany"));
            }

            if (!ModelState.IsValid)
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest));
            }

            var observation = _observationVmRepository.CreateNewObservationFromObservationVm(observationVm);

            var result = _observationRepository.AddObservation(observation);

            return(Request.CreateResponse(HttpStatusCode.OK,
                                          new string[] { result.ToString(), "success nowa Obserwacja dodana" }));
        }