示例#1
0
 public IActionResult UpdateLocation(Location location)
 {
     try
     {
         _locationServices.UpdateLocation(location);
         return(CreatedAtAction("UpdateLocation", location));
     }
     catch (Exception)
     {
         return(BadRequest());
     }
 }
        protected async Task HandleValidSubmit()
        {
            Mapper.Map(EditLocationModel, Location);

            Location result = null;

            if (Location.id != 0)
            {
                result = await LocationServices.UpdateLocation(Location);
            }
            else
            {
                result = await LocationServices.AddLocation(Location);
            }
            if (result != null)
            {
                Navigation.NavigateTo("/Libraries");
            }
        }
        public ActionResult EditLocation(int id, FormCollection collection)
        {
            var location = LocationServices.GetLocation(id);

            try
            {
                UpdateModel(location);
                LocationServices.UpdateLocation(location);

                return(RedirectToAction("LocationListing"));
            }
            catch (Exception ex)
            {
                // Invalid - redisplay with errors
                Logger.Error(ex.ToString());
                ModelState.AddModelError(String.Empty, Constants.ServerError);
                return(View("LocationDetail", location));
            }
        }