public ActionResult Edit(string id)
        {
            var location = this.locationService.GetById(id);

            //Verify if asset is from user organisation
            if (!this.IsMegaAdmin())
            {
                if (location.OrganisationId != this.userService.GetUserOrganisationId(this.User.Identity.GetUserId()))
                {
                    return(Redirect("/Home/NotAuthorized"));
                }
            }

            var viewModel = new EditLocationViewModel
            {
                OldCode      = location.Code,
                Country      = location.Country,
                Latitude     = location.Latitude,
                Longitude    = location.Longitude,
                Street       = location.Street,
                StreetNumber = location.StreetNumber.Value,
                Town         = location.Town
            };

            return(View(viewModel));
        }
        public ViewResult EditLocation(OnlandVisualTrashAssessmentAreaPrimaryKey onlandVisualTrashAssessmentAreaPrimaryKey)
        {
            var onlandVisualTrashAssessmentArea = onlandVisualTrashAssessmentAreaPrimaryKey.EntityObject;
            var viewModel = new EditLocationViewModel(onlandVisualTrashAssessmentArea);

            return(ViewEditLocation(onlandVisualTrashAssessmentArea, viewModel));
        }
        public IActionResult EditLocation([FromRoute] string Id)
        {
            try
            {
                var locationToUpdate = customerService.GetLocationAddress(Id);

                var editLocationViewModel = new EditLocationViewModel()
                {
                    Id           = Id,
                    Country      = locationToUpdate.Country,
                    City         = locationToUpdate.City,
                    Street       = locationToUpdate.Street,
                    StreetNumber = locationToUpdate.StreetNumber,
                    PostalCode   = locationToUpdate.PostalCode
                };

                return(PartialView("_EditLocationPartial", editLocationViewModel));
            }
            catch (Exception e)
            {
                logger.LogError("Failed to update location entity at Get {@Exception}", e.Message);
                logger.LogDebug("Failed to update location entity at Get {@ExceptionMessage}", e);
                return(BadRequest("Failed to update location entity"));
            }
        }
        public IActionResult EditLocation([FromForm] EditLocationViewModel updatedLocation)
        {
            if (!ModelState.IsValid || updatedLocation == null)
            {
                return(PartialView("_EditLocationPartial", new EditLocationViewModel()));
            }

            try
            {
                var locationToUpdate = customerService.GetLocationAddress(updatedLocation.Id);

                customerService.UpdateLocationAddress(locationToUpdate.Id,
                                                      updatedLocation.Country,
                                                      updatedLocation.City,
                                                      updatedLocation.Street,
                                                      updatedLocation.StreetNumber,
                                                      updatedLocation.PostalCode);

                return(PartialView("_EditLocationPartial", updatedLocation));
            }
            catch (Exception e)
            {
                logger.LogError("Failed to edit location entity {@Exception}", e.Message);
                logger.LogDebug("Failed to edit location entity {@ExceptionMessage}", e);
                return(BadRequest("Failed to edit location entity"));
            }
        }
Exemplo n.º 5
0
        public ViewResult EditLocation(FocusAreaPrimaryKey focusAreaPrimaryKey)
        {
            var viewModel = new EditLocationViewModel();
            var viewData  = new EditLocationViewData(CurrentPerson, focusAreaPrimaryKey.EntityObject);

            return(RazorView <EditLocation, EditLocationViewData, EditLocationViewModel>(viewData, viewModel));
        }
        public ActionResult Edit(EditLocationViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            if ((model.Longitude != null && model.Latitude != null) ||
                (model.Country != null && model.Town != null && model.Street != null))
            {
                this.locationService.Update((new Location
                {
                    Code = model.OldCode,
                    Country = model.Country,
                    Latitude = model.Latitude,
                    Longitude = model.Longitude,
                    Street = model.Street,
                    StreetNumber = model.StreetNumber != null ? model.StreetNumber.Value : 0,
                    Town = model.Town
                }));
                return(Redirect("/HelpModule/Location/Index"));
            }
            ModelState.AddModelError("", LocationTr.Validate);
            return(View(model));
        }
Exemplo n.º 7
0
        /// <summary>
        /// Calls API to edit location
        /// </summary>
        /// <param name="model">EditLocationViewModel model containing data to be updated</param>
        private void EditLocationCall(EditLocationViewModel model)
        {
            var request = new RestRequest("TimelineEvent/EditLocation");

            if (!PutRequest(request, model).Equals("OK")) //Error handling
            {
                throw new System.ArgumentException("Parameter cannot be null", "original");
            }
        }
Exemplo n.º 8
0
        public JsonResult Update(int locID, string newName, string newAdress, string newHours, string newDescription)
        {
            EditLocationViewModel model = new EditLocationViewModel()
            {
                ID = locID, Name = newName, Adress = newAdress, Hours = newHours, Description = newDescription
            };
            bool locationUpdated = EditLocationViewModel.UpdateMarker(context, model);

            return(new JsonResult(locationUpdated));
        }
Exemplo n.º 9
0
        public IActionResult EditLocation()
        {
            string userID = userManager.GetUserId(User);
            List <EditLocationViewModel> locationList = EditLocationViewModel.DisplayList(context, userID);

            if (locationList == null)
            {
                ViewData["Message"] = "Du har inte lagt till några skötbord";
            }
            return(View(locationList));
        }
Exemplo n.º 10
0
        public ActionResult Edit(int id)
        {
            var model = new EditLocationViewModel();

            PrepareViewModel(model, EvolutionResources.bnrAddEditLocation);

            model.Location           = LookupService.FindLocationModel(id);
            model.Location.CompanyId = model.CurrentCompany.Id;
            model.LGS = LookupService.LockLocation(model.Location);

            return(View(model));
        }
Exemplo n.º 11
0
        /// <summary>
        /// Removes a location from an Event
        /// </summary>
        /// <param name="Id">Id of event to have location removed</param>
        /// <returns>Redirect to TimelineView</returns>
        public IActionResult RemoveLocation(string Id)
        {
            EditLocationViewModel model = new EditLocationViewModel(Id, null); //creates model with null to have location removed

            var request = new RestRequest("TimelineEvent/EditLocation");

            if (!(PutRequest(request, model)).Equals("OK")) //error handling
            {
                return(RedirectToAction("APIError"));
            }
            _toastNotification.AddWarningToastMessage("The event location has been removed!");
            return(RedirectToAction("TimelineView", new { id = GetTimelineID(model.TimelineEventId) })); //returns to the Index!
        }
Exemplo n.º 12
0
 public IActionResult EditLocation(EditLocationViewModel model)
 {
     try                          //Error handling
     {
         EditLocationCall(model); //Calls Editlocation
     }
     catch
     {
         return(RedirectToAction("APIError"));
     }
     _toastNotification.AddInfoToastMessage("The event location has been edited!");
     return(RedirectToAction("TimelineView", new { id = GetTimelineID(model.TimelineEventId) })); //returns to the Index!
 }
Exemplo n.º 13
0
        public ActionResult EditLocation(FocusAreaPrimaryKey focusAreaPrimaryKey, EditLocationViewModel viewModel)
        {
            var focusArea = focusAreaPrimaryKey.EntityObject;

            if (!ModelState.IsValid)
            {
                var viewData = new EditLocationViewData(CurrentPerson, focusArea);
                return(RazorPartialView <EditLocationErrors, EditLocationViewData, EditLocationViewModel>(viewData, viewModel));
            }

            viewModel.UpdateModel(focusArea);

            return(RedirectToAction(new SitkaRoute <FocusAreaController>(c => c.ApproveUploadGis(focusAreaPrimaryKey))));
        }
Exemplo n.º 14
0
        public async Task <IActionResult> EditLocation(EditLocationViewModel model)
        {
            if (ModelState.IsValid)
            {
                Location location = locationRepository.GetById(model.Id);
                location.Title   = model.Title;
                location.AdminId = await GetCurrentLoggedInUserId();

                location.Number             = model.Number;
                location.LocationCategoryId = model.CategoryId;
                locationRepository.Update(location);
                locationRepository.Save();
                TempData["edited"] = $"Location { model.Title } has been successfully updated.";
                return(Json(new { success = true }));
            }
            GetAllCategories(model);
            return(PartialView(model));
        }
Exemplo n.º 15
0
        public IHttpActionResult Put(EditLocationViewModel editModel)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var locationData = _locationService.GetLocationById(editModel.Id);

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

            AutoMapper.Mapper.Map(editModel, locationData);
            _locationService.UpdateLoaction(locationData);

            return(StatusCode(HttpStatusCode.NoContent));
        }
Exemplo n.º 16
0
        public IActionResult EditLocation(long Id)
        {
            var location = locationRepository.GetById(Id);

            if (location == null)
            {
                ViewBag.ErrorMessage = $"location resource with { Id } not found";
                return(View("Error"));
            }
            EditLocationViewModel model = new EditLocationViewModel
            {
                Id         = location.Id,
                Title      = location.Title,
                Number     = location.Number,
                CategoryId = location.LocationCategoryId
            };

            GetAllCategories(model);
            return(PartialView(model));
        }
        public async Task <bool> EditLocation(EditLocationViewModel model)
        {
            var location = GetLocation(model.LocationId);

            if (location != null)
            {
                try
                {
                    _context.Locations.Attach(location);
                    location.LocationName = model.LocationName;
                    var result = await _context.SaveChangesAsync();

                    return(result > 0);
                }
                catch (Exception)
                {
                    return(false);
                }
            }
            return(false);
        }
Exemplo n.º 18
0
 public ActionResult Save(EditLocationViewModel model, string command)
 {
     if (command.ToLower() == "save")
     {
         var modelError = LookupService.InsertOrUpdateLocation(model.Location, CurrentUser, model.LGS);
         if (modelError.IsError)
         {
             PrepareViewModel(model, EvolutionResources.bnrAddEditLocation);
             model.SetErrorOnField(ErrorIcon.Error, modelError.Message, "Location_" + modelError.FieldName);
             return(View("Edit", model));
         }
         else
         {
             return(RedirectToAction("Locations"));
         }
     }
     else
     {
         return(RedirectToAction("Locations"));
     }
 }
Exemplo n.º 19
0
        public async Task <IActionResult> Edit(EditLocationViewModel model)
        {
            MessageVM userMessage = new MessageVM();

            if (ModelState.IsValid)
            {
                if (await _locationServices.EditLocation(model))
                {
                    userMessage = new MessageVM()
                    {
                        CssClassName = "alert alert-success ", Title = "Thành công", Message = "Chỉnh sửa địa điểm thành công"
                    };
                    TempData["UserMessage"] = JsonConvert.SerializeObject(userMessage);
                    return(RedirectToAction(actionName: "Index"));
                }
            }
            userMessage = new MessageVM()
            {
                CssClassName = "alert alert-danger ", Title = "Không thành công", Message = "Thao tác thất bại, xin mời thử lại"
            };
            TempData["UserMessage"] = JsonConvert.SerializeObject(userMessage);
            return(RedirectToAction(actionName: "Index"));
        }
Exemplo n.º 20
0
        public PartialViewResult EditLocation(string Id, string Location)
        {
            EditLocationViewModel model = new EditLocationViewModel(Id, Location);

            return(PartialView("_EditLocation", model));
        }
 public EditLocationPage()
 {
     InitializeComponent();
     BindingContext = _viewModel = new EditLocationViewModel();
 }
        public ActionResult EditLocation(OnlandVisualTrashAssessmentAreaPrimaryKey onlandVisualTrashAssessmentAreaPrimaryKey, EditLocationViewModel viewModel)
        {
            var onlandVisualTrashAssessmentArea = onlandVisualTrashAssessmentAreaPrimaryKey.EntityObject;

            if (!ModelState.IsValid)
            {
                return(ViewEditLocation(onlandVisualTrashAssessmentArea, viewModel));
            }

            viewModel.UpdateModel(onlandVisualTrashAssessmentArea);

            SetMessageForDisplay("Successfully updated OVTA Area location");

            return(Redirect(
                       SitkaRoute <OnlandVisualTrashAssessmentAreaController> .BuildUrlFromExpression(x =>
                                                                                                      x.Detail(onlandVisualTrashAssessmentAreaPrimaryKey))));
        }
Exemplo n.º 23
0
        public JsonResult Delete(int id)
        {
            bool locationDeleted = EditLocationViewModel.DeleteMarker(context, id);

            return(new JsonResult(locationDeleted));
        }
        private ViewResult ViewEditLocation(OnlandVisualTrashAssessmentArea onlandVisualTrashAssessmentArea, EditLocationViewModel viewModel)
        {
            var assessmentAreaLayerGeoJson      = onlandVisualTrashAssessmentArea.GetAssessmentAreaLayerGeoJson();
            var transectLineLayerGeoJson        = onlandVisualTrashAssessmentArea.GetTransectLineLayerGeoJson();
            var refineAssessmentAreaMapInitJson = new RefineAssessmentAreaMapInitJson("refineAssessmentAreaMap", null, assessmentAreaLayerGeoJson, transectLineLayerGeoJson);

            var viewData = new EditLocationViewData(CurrentPerson, onlandVisualTrashAssessmentArea, refineAssessmentAreaMapInitJson);

            return(RazorView <EditLocation, EditLocationViewData, EditLocationViewModel>(viewData, viewModel));
        }