示例#1
0
        public ActionResult Create(Trucker trucker)
        {
            var userId = User.FindFirstValue(ClaimTypes.NameIdentifier);

            try
            {
                // TODO: Add insert logic here
                var coords = _geocode.GetCoords(trucker);
                trucker.Latitude       = coords.Result.results[0].geometry.location.lat;
                trucker.Longitude      = coords.Result.results[0].geometry.location.lng;
                trucker.IdentityUserId = userId;
                _repo.Trucker.Create(trucker);
                _repo.Save();
                return(RedirectToAction(nameof(Index)));
            }
            catch
            {
                return(View());
            }
        }