public IHttpActionResult Get(int id)
 {
     var location = locationService.GetLocationById(id);
     var viewModel = new LocationViewModel();
     Mapper.Map(location, viewModel);
     return Ok(viewModel);
 }
        public IHttpActionResult Put(int id, LocationViewModel locationViewModel)
        {
            string userEmail = Thread.CurrentPrincipal.Identity.Name;
            var user = userService.GetUserByEmail(userEmail);

            if (user != null)
            {
                locationViewModel.Id = id;
                var location = locationService.GetLocationById(id);
                Mapper.Map(locationViewModel, location);
                location.UserId = user.Id;
                locationService.UpdateLoaction(location);
                return Ok(locationViewModel);
            }
            return InternalServerError();
        }
        public IHttpActionResult Post(LocationViewModel location)
        {
            string userEmail = Thread.CurrentPrincipal.Identity.Name;
            var user = userService.GetUserByEmail(userEmail);

            if (user != null)
            {
                Location entity = new Location();
                Mapper.Map(location, entity);
                entity.CreatedOn = DateTime.UtcNow;
                entity.UserId = user.Id;
                locationService.AddLocation(entity);
                Mapper.Map(entity, location);
                return Created(Url.Link("DefaultApi", new { controller = "Locations", id = location.Id }), location);
            }
            return InternalServerError();
        }