Ejemplo n.º 1
0
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            LocationEditVM = await _context.Location.Select(l => new LocationEditViewModel()
            {
                LocationID     = l.LocationID,
                LocationCode   = l.LocationCode,
                AddressID      = l.AddressID,
                DivisionID     = l.DivisionID,
                BusinessUnitID = l.BusinessUnitID,
                FirstAddress   = l.Address.FirstAddress,
                SecondAddress  = l.Address.SecondAddress,
                City           = l.Address.City,
                StateProvince  = l.Address.StateProvince,
                Country        = l.Address.Country,
                Longitude      = l.Address.Longitude,
                Lattitude      = l.Address.Lattitude
            }).FirstOrDefaultAsync(l => l.LocationID == id);

            if (LocationEditVM == null)
            {
                return(NotFound());
            }

            ViewData["AddressID"]      = new SelectList(_context.Address, "AddressID", "Country");
            ViewData["DivisionID"]     = new SelectList(_context.Division, "DivisionID", "DivisionName");
            ViewData["BusinessUnitID"] = new SelectList(_context.BusinessUnit, "BusinessUnitID", "BusinessUnitName");
            return(Page());
        }
        public IActionResult EditLocationPost(LocationEditViewModel model)
        {
            var farm = _farm.EditLocation(model, GetCurrentUserAsync().Result.UserName).Result;

            if (ModelState.IsValid)
            {
                if (farm.Succeeded)
                {
                    _toastNotification.AddSuccessToastMessage(farm.OkMessage, new ToastrOptions
                    {
                        PositionClass = ToastPositions.TopCenter
                    });
                    return(RedirectToAction(nameof(ListLocation)));
                }

                _toastNotification.AddWarningToastMessage(farm.Errors, new ToastrOptions
                {
                    PositionClass = ToastPositions.TopCenter
                });
                return(View(nameof(EditLocation), model));
            }

            _toastNotification.AddWarningToastMessage(farm.Errors, new ToastrOptions
            {
                PositionClass = ToastPositions.TopCenter
            });
            return(View(nameof(EditLocation), model));
        }
Ejemplo n.º 3
0
 public static Location UpdateModel(this Location location, LocationEditViewModel locationEditModel)
 {
     if (locationEditModel != null)
     {
         var locationInfo = string.Concat(locationEditModel.Address1?.Trim(), locationEditModel.Address2?.Trim(), locationEditModel.City?.Trim(), locationEditModel.State?.Trim(), locationEditModel.PostalCode?.Trim(), locationEditModel.Name?.Trim(), locationEditModel.PhoneNumber?.Trim());
         if (string.IsNullOrWhiteSpace(locationInfo))
         {
             location = null;
         }
         else
         {
             if (location == null || locationEditModel.Id.GetValueOrDefault() != 0)
             {
                 location = new Location();
             }
             location.Address1    = locationEditModel.Address1;
             location.Address2    = locationEditModel.Address2;
             location.City        = locationEditModel.City;
             location.Country     = locationEditModel.Country;
             location.Name        = locationEditModel.Name;
             location.PhoneNumber = locationEditModel.PhoneNumber;
             location.PostalCode  = locationEditModel.PostalCode;
             location.State       = locationEditModel.State;
             return(location);
         }
     }
     return(location);
 }
Ejemplo n.º 4
0
 public static Location UpdateModel(this Location location, LocationEditViewModel locationEditModel)
 {
     if (locationEditModel != null)
     {
         var locationInfo = string.Concat(locationEditModel.Address1?.Trim(), locationEditModel.Address2?.Trim(), locationEditModel.City?.Trim(), locationEditModel.State?.Trim(), locationEditModel.PostalCode?.Trim(), locationEditModel.Name?.Trim(), locationEditModel.PhoneNumber?.Trim());
         if (string.IsNullOrWhiteSpace(locationInfo))
         {
             location = null;
         }
         else
         {
             if (location == null || locationEditModel.Id.GetValueOrDefault() != 0)
             {
                 location = new Location();
             }
             location.Address1 = locationEditModel.Address1;
             location.Address2 = locationEditModel.Address2;
             location.City = locationEditModel.City;
             location.Country = locationEditModel.Country;
             location.Name = locationEditModel.Name;
             location.PhoneNumber = locationEditModel.PhoneNumber;
             location.PostalCode = locationEditModel.PostalCode;
             location.State = locationEditModel.State;
             return location;
         }
     }
     return location;
 }
Ejemplo n.º 5
0
 public IActionResult Edit(LocationEditViewModel locationEditViewModel, int id)
 {
     if (!ModelState.IsValid)
     {
         return(View(new LocationEditViewModel()));
     }
     locationEditViewModel.Persist(id, context);
     return(RedirectToAction(actionName: nameof(Index)));
 }
Ejemplo n.º 6
0
        private void CancelEditLocation()
        {
            _editHasUnsavedChanges = false;
            _locationEditViewModel = null;

            OnPropertyChanged(nameof(EditingLocation));
            OnPropertyChanged(nameof(IsEditingLocation));
            OnPropertyChanged(nameof(HasUnsavedChanges));
        }
Ejemplo n.º 7
0
        public ActionResult Edit(int ID, string SearchText)
        {
            try
            {
                var locationEditViewModel = new LocationEditViewModel();
                if (ID > 0)
                {
                    REF_LOCATION_TB location = _uow.Repository <REF_LOCATION_TB>().GetById(ID);
                    locationEditViewModel.Description       = location.SZ_DESCRIPTION;
                    locationEditViewModel.EffectiveDate     = location.DT_EFFECTIVE == null ? "" : location.DT_EFFECTIVE.Value.ToShortDateString();
                    locationEditViewModel.ExpiredDate       = location.DT_EXPIRED == null ? "" : location.DT_EXPIRED.Value.ToShortDateString();
                    locationEditViewModel.LocationID        = ID;
                    locationEditViewModel.SearchText        = SearchText;
                    locationEditViewModel.SelectedWaterBody = Convert.ToInt32(location.N_WATER_BODY_SYSID);
                    locationEditViewModel.SelectedWaterShed = Convert.ToInt32(location.N_LOCATION_TYPE_SYSID);
                    locationEditViewModel.Station           = location.SZ_LABEL;
                    locationEditViewModel.WaterBodies       = (List <SelectListItem>)_waterBodyRepo.GetWaterBodies();
                    locationEditViewModel.WaterSheds        = (List <SelectListItem>)_waterShedRepo.GetWaterSheds();
                    locationEditViewModel.XCoordinate       = Convert.ToDouble(location.N_GIS_X);
                    locationEditViewModel.YCoordinate       = Convert.ToDouble(location.N_GIS_Y);
                    locationEditViewModel.OrderUpDown       = location.SZ_STREAM_NUMBER;
                }
                else
                {
                    locationEditViewModel.Description       = "";
                    locationEditViewModel.EffectiveDate     = "";
                    locationEditViewModel.ExpiredDate       = "";
                    locationEditViewModel.LocationID        = ID;
                    locationEditViewModel.SearchText        = SearchText;
                    locationEditViewModel.SelectedWaterBody = 0;
                    locationEditViewModel.SelectedWaterShed = 0;
                    locationEditViewModel.Station           = "";
                    locationEditViewModel.WaterBodies       = (List <SelectListItem>)_waterBodyRepo.GetWaterBodies();
                    locationEditViewModel.WaterSheds        = (List <SelectListItem>)_waterShedRepo.GetWaterSheds();
                    locationEditViewModel.XCoordinate       = 0;
                    locationEditViewModel.YCoordinate       = 0;
                    locationEditViewModel.OrderUpDown       = "";
                }

                return(View("Edit", locationEditViewModel));
            }
            catch (Exception ex)
            {
                if (ex.InnerException == null)
                {
                    ViewBag.Message = "Function: LocationController.Edit_GET\n\nError: " + ex.Message;
                }
                else
                {
                    ViewBag.Message = "Function: LocationController.Edit_GET\n\nError: " + (ex.Message + "\n\nInnerException: " + ex.InnerException.Message);
                };
                Session["ErrorMessage"] = ViewBag.Message;
                return(RedirectToAction("InternalServerError", "Error"));
            };
        }
        public ActionResult Edit(LocationEditViewModel model)
        {
            if (ModelState.IsValid)
            {
                _locationService.SaveLocation(model);

                return(RedirectToAction("Index"));
            }

            return(View(model));
        }
        public ActionResult Create(LocationEditViewModel model)
        {
            if (ModelState.IsValid)
            {
                var newId = _locationService.SaveLocation(model);

                return(RedirectToAction("View", new { id = newId }));
            }

            return(View(model));
        }
Ejemplo n.º 10
0
 public Location(LocationEditViewModel from)
 {
     Address1    = from.Address1;
     Address2    = from.Address2;
     City        = from.City;
     State       = from.State;
     PostalCode  = from.PostalCode;
     Name        = from.Name;
     PhoneNumber = from.PhoneNumber;
     Country     = from.Country;
 }
Ejemplo n.º 11
0
        private void EditLocation(LocationViewModel locationModel)
        {
            if (locationModel != null)
            {
                _locationEditViewModel = new LocationEditViewModel(locationModel.LocationModel);
                _locationEditViewModel.PropertyChanged += _locationEditViewModel_PropertyChanged;

                OnPropertyChanged(nameof(EditingLocation));
                OnPropertyChanged(nameof(IsEditingLocation));
            }
        }
Ejemplo n.º 12
0
        public IActionResult Edit(int LocationId, LocationEditViewModel location)
        {
            if (!ModelState.IsValid)
            {
                location.ResetCategoryList(context);
                return(View(location));
                //return View(new LocationEditViewModel());
            }

            location.Persist(LocationId, context);
            return(RedirectToAction(actionName: nameof(Index)));
        }
        public ActionResult Edit(LocationEditViewModel model)
        {
            var currentLocation = locationRepo.ResultTable.Where(x => x.Id == model.Id).FirstOrDefault();
            var selectedCity    = currentLocation.CityId;

            if (model.SelectedCity != "")
            {
                selectedCity = Convert.ToInt16(model.SelectedCity);
            }
            var selectedCounty = currentLocation.CountyId;

            if (model.SelectedCounty != "")
            {
                selectedCounty = Convert.ToInt16(model.SelectedCounty);
            }


            if (currentLocation.CityId != selectedCity)
            {
                currentLocation.City = _currentDb.Cities.Where(x => x.Id == selectedCity).FirstOrDefault();
            }

            if (currentLocation.CountyId != selectedCounty)
            {
                currentLocation.County = _currentDb.Counties.Where(x => x.Id == selectedCounty).FirstOrDefault();
            }

            if (model.LocationName != null)
            {
                currentLocation.LocationName = model.LocationName;
            }

            if (model.LocationDescription != null)
            {
                currentLocation.LocationDescription = model.LocationDescription;
            }


            try
            {
                var location = locationRepo.Save(currentLocation);

                return(RedirectToAction("details", new { id = location.Id }));
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                return(View());
            }
        }
        public IActionResult EditLocation(long id)
        {
            var location     = _farm.GetLocationById(id);
            var editLocation = new LocationEditViewModel
            {
                Id          = location.Id,
                Name        = location.Name,
                Active      = location.Active,
                Code        = location.Code,
                Description = location.Description,
            };

            ViewBag.Code = location.Code;
            return(View(editLocation));
        }
Ejemplo n.º 15
0
        public ActionResult Edit(int?id)
        {
            DbLocation location = GetLocationIfExistsAndUserHasAccess(id);

            if (location == null)
            {
                return(RedirectToAction("Index"));
            }

            ViewBag.Location   = location;
            ViewBag.LocationId = location.Id;

            LocationEditViewModel locationModel = location.ToLocationEditValidationModel();

            return(View(locationModel));
        }
Ejemplo n.º 16
0
        public ActionResult EditPost(int id, LocationEditViewModel model)
        {
            try
            {
                DbLocation location = GetLocationIfExistsAndUserHasAccess(id);
                if (location == null)
                {
                    return(RedirectToAction("Index"));
                }

                if (!ModelState.IsValid)
                {
                    return(View(model));
                }

                if (location == null)
                {
                    return(RedirectToAction("Index", "Home"));
                }

                LocationsRepository locationsRepository = _unitOfWork.LocationsRepository;
                location.Name              = model.Name;
                location.Description       = model.Description;
                location.Organisation      = model.Organisation;
                location.PricePerDay       = model.PricePerDay;
                location.Capacity          = model.Capacity;
                location.AddressCity       = model.AddressCity;
                location.AddressNumber     = model.AddressNumber;
                location.AddressPostalCode = model.AddressPostalCode;
                location.AddressProvince   = model.AddressProvince;
                location.AddressStreet     = model.AddressStreet;
                locationsRepository.Update(location);

                TempData["AlertType"]    = "success";
                TempData["AlertMessage"] = "De aanpassingen zijn correct opgeslagen.";

                return(RedirectToAction("Edit", new { id = id }));
            }
            catch
            {
                TempData["AlertType"]    = "danger";
                TempData["AlertMessage"] = "Er is iets fout gelopen tijdens het verwerken van de aanpassingen!";

                return(View(model));
            }
        }
        public ActionResult Edit(Guid?id)
        {
            if (!id.HasValue)
            {
                return(RedirectToAction("Index"));
            }

            var loc = _locationService.GetLocation(id.Value);
            var vm  = new LocationEditViewModel();

            if (loc != null)
            {
                vm.Name       = loc.Name;
                vm.LocationId = loc.LocationId;
            }

            return(View(vm));
        }
Ejemplo n.º 18
0
 public ActionResult Edit(string LocationId)
 {
     try
     {
         int             LocId    = int.Parse(LocationId);
         IIotContextBase icont    = (iotContext)System.Web.HttpContext.Current.Session["iotcontext"];
         string          domainId = DomainSession.GetContextDomain(this.HttpContext);
         iotDomain       d        = icont.Domains.First(dm => dm.DomainName.Equals(domainId));
         Location        loc      = d.Locations.First(l => l.Id == LocId);
         if (loc != null)
         {
             LocationEditViewModel model = new LocationEditViewModel(loc);
             return(View(model));
         }
     }
     catch (Exception e)
     {
     }
     return(View());
 }
Ejemplo n.º 19
0
        private bool SaveEditLocation()
        {
            bool saved = false;

            if (_locationEditViewModel.LocationModel != null)
            {
                _locationEditViewModel.LocationModel.Id = _selectedLocation.LocationModel.Id;
                _compendium.UpdateLocation(_locationEditViewModel.LocationModel);

                _selectedLocation = new LocationViewModel(_locationEditViewModel.LocationModel);

                ListItemViewModel <LocationModel> oldListItem = _locations.FirstOrDefault(x => x.Model.Id == _locationEditViewModel.LocationModel.Id);
                if (oldListItem != null)
                {
                    if (_locationSearchService.SearchInputApplies(_locationSearchInput, _locationEditViewModel.LocationModel))
                    {
                        InitializeListItemDetails(oldListItem, _locationEditViewModel.LocationModel);
                    }
                    else
                    {
                        _locations.Remove(oldListItem);
                    }
                }

                _locationEditViewModel = null;
                _editHasUnsavedChanges = false;

                SortLocations();

                _compendium.SaveLocations();

                OnPropertyChanged(nameof(SelectedLocation));
                OnPropertyChanged(nameof(EditingLocation));
                OnPropertyChanged(nameof(IsEditingLocation));
                OnPropertyChanged(nameof(HasUnsavedChanges));

                saved = true;
            }

            return(saved);
        }
        public static LocationEditViewModel ToLocationEditValidationModel(this DbLocation entity)
        {
            if (entity == null)
            {
                return(null);
            }

            var mappedEntity = new LocationEditViewModel();

            mappedEntity.Name              = entity.Name;
            mappedEntity.Description       = entity.Description;
            mappedEntity.Organisation      = entity.Organisation;
            mappedEntity.PricePerDay       = entity.PricePerDay;
            mappedEntity.Capacity          = entity.Capacity;
            mappedEntity.AddressCity       = entity.AddressCity;
            mappedEntity.AddressNumber     = entity.AddressNumber;
            mappedEntity.AddressPostalCode = entity.AddressPostalCode;
            mappedEntity.AddressProvince   = entity.AddressProvince;
            mappedEntity.AddressStreet     = entity.AddressStreet;
            return(mappedEntity);
        }
Ejemplo n.º 21
0
        private void Add()
        {
            bool addLocation = true;

            if (_locationEditViewModel != null)
            {
                if (_editHasUnsavedChanges)
                {
                    string body = String.Format("{0} has unsaved changes.{1}What would you like to do?",
                                                _selectedLocation.Name, Environment.NewLine + Environment.NewLine);
                    string accept = "Save and Continue";
                    string reject = "Discard Changes";
                    string cancel = "Cancel Navigation";
                    bool?  result = _dialogService.ShowConfirmationDialog("Unsaved Changes", body, accept, reject, cancel);

                    if (result == true)
                    {
                        if (!SaveEditLocation())
                        {
                            addLocation = false;
                        }
                    }
                    else if (result == false)
                    {
                        CancelEditLocation();
                    }
                    else
                    {
                        addLocation = false;
                    }
                }
                else
                {
                    CancelEditLocation();
                }
            }

            if (addLocation)
            {
                LocationModel locationModel = new LocationModel();

                _compendium.AddLocation(locationModel);

                if (_locationSearchService.SearchInputApplies(_locationSearchInput, locationModel))
                {
                    ListItemViewModel <LocationModel> listItem = new ListItemViewModel <LocationModel>(locationModel);
                    InitializeListItemDetails(listItem, locationModel);
                    _locations.Add(listItem);
                    foreach (ListItemViewModel <LocationModel> item in _locations)
                    {
                        item.IsSelected = false;
                    }
                    listItem.IsSelected = true;
                }

                _selectedLocation = new LocationViewModel(locationModel);

                _locationEditViewModel = new LocationEditViewModel(locationModel);
                _locationEditViewModel.PropertyChanged += _locationEditViewModel_PropertyChanged;

                SortLocations();

                _compendium.SaveLocations();

                OnPropertyChanged(nameof(EditingLocation));
                OnPropertyChanged(nameof(IsEditingLocation));
                OnPropertyChanged(nameof(SelectedLocation));
            }
        }
 public LocationEditView(LocationEditViewModel locationEditViewModel)
 {
     this.DataContext = locationEditViewModel;
     this.InitializeComponent();
 }
        // GET: Location/Edit/5
        public ActionResult Edit(int id)
        {
            var model = new LocationEditViewModel(_currentDb, id);

            return(View(model));
        }
Ejemplo n.º 24
0
        public ActionResult Edit(LocationEditViewModel Model)
        {
            bool saveFailed;

            do
            {
                saveFailed = false;
                try
                {
                    if (ModelState["XCoordinate"].Errors.Count > 0)
                    {
                        string   code     = ModelState["XCoordinate"].Value.AttemptedValue.ToString();
                        string[] parts    = code.Split(',');
                        string   entry    = parts[0];
                        string   response = "The value: '" + entry + "' is not valid. Please enter a numeric value.";
                        ModelState.Remove("XCoordinate");
                        ModelState.AddModelError("XCoordinate", response);
                    }

                    if (ModelState["YCoordinate"].Errors.Count > 0)
                    {
                        string   code     = ModelState["YCoordinate"].Value.AttemptedValue.ToString();
                        string[] parts    = code.Split(',');
                        string   entry    = parts[0];
                        string   response = "The value: '" + entry + "' is not valid. Please enter a numeric value.";
                        ModelState.Remove("YCoordinate");
                        ModelState.AddModelError("YCoordinate", response);
                    }
                    if (ModelState["SelectedWaterBody"].Errors.Count > 0)
                    {
                        Model.SelectedWaterBody = null;
                        ModelState.Remove("SelectedWaterBody");
                    }
                    if (ModelState["SelectedWaterShed"].Errors.Count > 0)
                    {
                        Model.SelectedWaterShed = null;
                        ModelState.Remove("SelectedWaterShed");
                    }

                    if (ModelState.IsValid)
                    {
                        int id = 0;
                        if (Model.LocationID == 0) //new
                        {
                            REF_LOCATION_TB location = new REF_LOCATION_TB()
                            {
                                B_INACTIVE            = false,
                                DT_EFFECTIVE          = Model.EffectiveDate == "" ? (DateTime?)null : Convert.ToDateTime(Model.EffectiveDate),
                                DT_ENTERED            = DateTime.UtcNow,
                                DT_EXPIRED            = Model.ExpiredDate == "" ? (DateTime?)null : Convert.ToDateTime(Model.ExpiredDate),
                                DT_MODIFIED           = DateTime.UtcNow,
                                N_GIS_X               = Convert.ToDecimal(Model.XCoordinate),
                                N_GIS_Y               = Convert.ToDecimal(Model.YCoordinate),
                                N_LOCATION_TYPE_SYSID = Model.SelectedWaterShed,
                                N_WATER_BODY_SYSID    = Model.SelectedWaterBody,
                                SZ_DESCRIPTION        = Model.Description,
                                SZ_ENTERED_BY         = _modifiedBy,
                                SZ_LABEL              = Model.Station,
                                SZ_MODIFIED_BY        = _modifiedBy,
                                SZ_STREAM_NUMBER      = Model.OrderUpDown
                            };
                            _uow.Repository <REF_LOCATION_TB>().Add(location);
                            _uow.SaveChanges();
                            DateTime        effectiveDate = Convert.ToDateTime(Model.EffectiveDate);
                            DateTime        expiredDate   = Convert.ToDateTime(Model.ExpiredDate);
                            Decimal         xCoord        = Convert.ToDecimal(Model.XCoordinate);
                            Decimal         yCoord        = Convert.ToDecimal(Model.YCoordinate);
                            REF_LOCATION_TB locationFound = _uow.Repository <REF_LOCATION_TB>().Find(u => u.SZ_ENTERED_BY == _modifiedBy &&
                                                                                                     u.SZ_MODIFIED_BY == _modifiedBy && u.DT_EFFECTIVE == effectiveDate && u.DT_EXPIRED == expiredDate &&
                                                                                                     u.N_GIS_X == xCoord && u.N_GIS_Y == yCoord && u.N_LOCATION_TYPE_SYSID == Model.SelectedWaterShed &&
                                                                                                     u.N_WATER_BODY_SYSID == Model.SelectedWaterBody && u.SZ_DESCRIPTION == Model.Description &&
                                                                                                     u.SZ_LABEL == Model.Station && u.SZ_STREAM_NUMBER == Model.OrderUpDown).FirstOrDefault();
                            id = locationFound.N_LOCATION_SYSID;
                        }
                        else //edit
                        {
                            REF_LOCATION_TB location = _uow.Repository <REF_LOCATION_TB>().GetById(Model.LocationID);
                            location.DT_EFFECTIVE          = Convert.ToDateTime(Model.EffectiveDate);
                            location.DT_EXPIRED            = Convert.ToDateTime(Model.ExpiredDate);
                            location.DT_MODIFIED           = DateTime.UtcNow;
                            location.N_GIS_X               = Convert.ToDecimal(Model.XCoordinate);
                            location.N_GIS_Y               = Convert.ToDecimal(Model.YCoordinate);
                            location.N_LOCATION_TYPE_SYSID = Model.SelectedWaterShed;
                            location.N_WATER_BODY_SYSID    = Model.SelectedWaterBody;
                            location.SZ_DESCRIPTION        = Model.Description;
                            location.SZ_LABEL              = Model.Station;
                            location.SZ_STREAM_NUMBER      = Model.OrderUpDown;
                            _uow.Repository <REF_LOCATION_TB>().Update(location);
                            _uow.SaveChanges();
                            id = Model.LocationID;
                        }

                        return(RedirectToAction("Index", new { ID = id, Search = Model.SearchText }));
                    }

                    Model.WaterBodies = (List <SelectListItem>)_waterBodyRepo.GetWaterBodies();
                    Model.WaterSheds  = (List <SelectListItem>)_waterShedRepo.GetWaterSheds();

                    return(View(Model));
                }
                catch (DbEntityValidationException ex)
                {
                    StringBuilder sb = new StringBuilder();

                    foreach (var failure in ex.EntityValidationErrors)
                    {
                        sb.AppendFormat("{0} failed validation:\n\n", failure.Entry.Entity.GetType());
                        foreach (var error in failure.ValidationErrors)
                        {
                            sb.AppendFormat("- {0} : {1}", error.PropertyName, error.ErrorMessage);
                            sb.AppendLine();
                        }
                    }
                    if (ex.InnerException == null)
                    {
                        ViewBag.Message = "Function: LocationController.Edit_POST\n\nError: " + ex.Message + "\n\n" + sb;
                    }
                    else
                    {
                        ViewBag.Message = "Function: LocationController.Edit_POST\n\nError: " + ex.Message + "\n\n" + sb + "\n\n" + ex.InnerException.Message;
                    };
                }
                catch (DbUpdateConcurrencyException ex)
                {
                    saveFailed = true;

                    var entry = ex.Entries.Single();
                    entry.OriginalValues.SetValues(entry.GetDatabaseValues());
                }
                catch (DataException ex)
                {
                    if (ex.InnerException == null)
                    {
                        ViewBag.Message = "Function: LocationController.Edit_POST\n\nError: " + ex.Message + "\n\nBaseException: " + ex.GetBaseException().Message;
                    }
                    else
                    {
                        ViewBag.Message = "Function: LocationController.Edit_POST\n\nError: " + ex.Message + "\n\nBaseException: " + ex.GetBaseException().Message + "\n\nInnerException: " + ex.InnerException.Message;
                    };
                }
                catch (Exception ex)
                {
                    if (ex.InnerException == null)
                    {
                        ViewBag.Message = "Function: LocationController.Edit_POST\n\nError: " + ex.Message;
                    }
                    else
                    {
                        ViewBag.Message = "Function: LocationController.Edit_POST\n\nError: " + ex.Message + "\n\nBaseException: " + ex.InnerException.Message;
                    };
                };
            } while (saveFailed);

            Session["ErrorMessage"] = ViewBag.Message;
            return(RedirectToAction("InternalServerError", "Error"));
        }