Beispiel #1
0
        public virtual IHttpActionResult SaveCurrentLocation([FromBody] LocationRequest locationRequest)
        {
            var response        = new InsertLocationResponse();
            var requestValidate = new ValidateRequestEngine(locationRequest);

            try
            {
                if (requestValidate.IsValid)
                {
                    LocationDa da = new LocationDa();
                    da.SaveChanges(LocationConverter.Convert(locationRequest));
                    response.Success = true;
                    response.Message = "Saved Location.";
                    da.Dispose();
                }
                else
                {
                    response.Success = false;
                    response.Message = requestValidate.Message;
                    return(new HttpActionResult(HttpStatusCode.BadRequest, response));
                }
            }
            catch (Exception ex)
            {
            }
            return(new HttpActionResult(HttpStatusCode.OK, response));
        }
Beispiel #2
0
        public virtual IHttpActionResult GetCurrentLocation()
        {
            var response = new GetLocationResponse();

            try
            {
                LocationDa da        = new LocationDa();
                var        latestLoc = da.GetLatestLocation();
                var        location  = LocationConverter.ConvertToReponse(latestLoc);
                var        json      = JsonConvert.SerializeObject(location, new JsonSerializerSettings {
                    Formatting = Formatting.None
                });
                response = JsonConvert.DeserializeObject <GetLocationResponse>(json);

                da.Dispose();
            }
            catch (Exception ex)
            {
            }
            return(new HttpActionResult(HttpStatusCode.OK, response));
        }