Exemplo n.º 1
0
        public UpdateLocationViewModel GetLocationForUpdateById(int LRowID)
        {
            try
            {
                UpdateLocationViewModel model = new UpdateLocationViewModel();
                var entity = db.MasterLocations.Find(LRowID);

                if (entity != null)
                {
                    model.LocationRowID = entity.LocationRowID;
                    model.LocationName  = entity.LocationName;
                    model.PinCode       = entity.PinCode;
                    model.CountryRowID  = entity.CountryRowID;
                    model.StateRowID    = entity.StateRowID;
                    model.DistrictRowID = entity.DistrictRowID;
                }
                else
                {
                    throw new Exception("Invalid Id!");
                }

                return(model);
            }
            catch (Exception)
            {
                throw;
            }
        }
        public IActionResult UpdateLocation([FromBody] UpdateLocationViewModel model)
        {
            var item = _context.Items.Include(i => i.Location).FirstOrDefault(i => i.Id == model.Id);

            if (item == null)
            {
                return(BadRequest("Nie ma przedmiotu o takim id."));
            }

            if (model.Location == 0)
            {
                item.Location = null;
            }
            else
            {
                var location = _context.Locations.FirstOrDefault(t => t.Id == model.Location);
                if (location == null)
                {
                    return(BadRequest("Nie ma takiego położenia."));
                }

                item.Location = location;
            }

            _context.SaveChanges();

            return(Ok());
        }
Exemplo n.º 3
0
        public IActionResult Update(UpdateLocationViewModel updateLocationViewModel)
        {
            if (!ModelState.IsValid)
            {
                return(View(updateLocationViewModel));
            }

            _meetingService.UpdateLocation(updateLocationViewModel.Location);
            return(RedirectToAction(nameof(Index)));
        }
Exemplo n.º 4
0
        public async Task UpdateLocationAsync(UpdateLocationViewModel location, EntityHeader user)
        {
            ValidationCheck(location, Core.Validation.Actions.Update);

            var locationFromStorage = await _locationRepo.GetLocationAsync(location.LocationId);

            ConcurrencyCheck(locationFromStorage, location.LastUpdatedDate);
            SetLastUpdated(locationFromStorage, user);

            await _locationRepo.UpdateLocationAsync(locationFromStorage);
        }
Exemplo n.º 5
0
        public async Task <IActionResult> UpdateLocation([FromBody] UpdateLocationViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            var user = await userManager.GetUserAsync(User);

            user.CurrentLocation = new PostgisPoint(model.Lon, model.Lat);
            context.Users.Update(user);
            context.SaveChanges();
            return(Ok());
        }
Exemplo n.º 6
0
        public async Task <InvokeResult> UpdateLocationAsync(UpdateLocationViewModel location, EntityHeader org, EntityHeader user)
        {
            var locationFromStorage = await _locationRepo.GetLocationAsync(location.LocationId);

            ConcurrencyCheck(locationFromStorage, location.LastUpdatedDate);
            SetLastUpdated(locationFromStorage, user);

            ValidationCheck(location, Core.Validation.Actions.Update);
            await AuthorizeAsync(locationFromStorage, AuthorizeResult.AuthorizeActions.Update, user, org);

            await _locationRepo.UpdateLocationAsync(locationFromStorage);

            return(InvokeResult.Success);
        }
Exemplo n.º 7
0
        public async Task <IActionResult> UpdateLocation(UpdateLocationViewModel model)
        {
            if (ModelState.IsValid)
            {
                var currentUser = await _userManager.GetUserAsync(HttpContext.User);

                if (currentUser.HomeId == null)
                {
                    return(BadRequest());
                }

                currentUser.IsHome = model.IsHome;

                await _repository.Commit();

                return(Ok());
            }

            return(BadRequest(ModelState));
        }
Exemplo n.º 8
0
        public UpdateLocationPage()
        {
            InitializeComponent();
            BindingContext = vm = new UpdateLocationViewModel();


            ToolbarItems.Add(new ToolbarItem
            {
                Text    = "Done",
                Command = new Command(async(obj) =>
                {
                    if (vm.IsBusy)
                    {
                        return;
                    }

                    await Navigation.PopModalAsync();
                })
            });
        }
Exemplo n.º 9
0
 public void UpdateLocation(UpdateLocationViewModel model)
 {
     try
     {
         if (model != null && model.LocationRowID > 0)
         {
             db.MasterLocations.Single(c => c.LocationRowID == model.LocationRowID).LocationName  = model.LocationName;
             db.MasterLocations.Single(c => c.LocationRowID == model.LocationRowID).DistrictRowID = model.DistrictRowID;
             db.MasterLocations.Single(c => c.LocationRowID == model.LocationRowID).StateRowID    = model.StateRowID;
             db.MasterLocations.Single(c => c.LocationRowID == model.LocationRowID).CountryRowID  = model.CountryRowID;
             db.MasterLocations.Single(c => c.LocationRowID == model.LocationRowID).PinCode       = model.PinCode;
         }
         else
         {
             throw new Exception("Location could not be blank!");
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
        public async Task <IActionResult> UpdateLocationAsync(UpdateLocationViewModel model)
        {
            try
            {
                LocationDto location = new LocationDto
                {
                    Id    = model.Location.Id,
                    Title = model.Location.Title
                };

                await locationService.UpdateAsync(location);

                return(RedirectToAction("LocationsList", "Location"));
            }
            catch (Exception ex)
            {
                ErrorViewModel errorModel = new ErrorViewModel();
                errorModel.ErrorMessage = ex.Message.ToString();

                return(View("Views/Shared/Error.cshtml", errorModel));
            }
        }
Exemplo n.º 11
0
        public async Task <UpdateLocationViewModel> GetUpdateLocationViewModelAsync(String locationId, EntityHeader org, EntityHeader user)
        {
            var location = await _locationRepo.GetLocationAsync(locationId);

            return(UpdateLocationViewModel.CreateForOrganizationLocation(location));
        }
 public UpdateLocationPage()
 {
     InitializeComponent();
     BindingContext = vm = new UpdateLocationViewModel();
 }