コード例 #1
0
        protected async override Task OnInitializedAsync()
        {
            Location = await LocationServices.GetLocation(int.Parse(Id));

            Books = (await BookServices.GetBooks()).ToList().Where(e => e.locationId == Location.id);

            await CountBooksNumber();
        }
コード例 #2
0
        public ActionResult EditLocation(int id)
        {
            var location = LocationServices.GetLocation(id);

            ViewBag.Action = "EditLocation";

            return(View("LocationDetail", location));
        }
コード例 #3
0
ファイル: MainViewModel.cs プロジェクト: MohanadDabab/Dalel
        private async Task InitData()
        {
            var LocationService = new LocationServices();

            DoneFetch    = true;
            LocationList = await LocationService.GetLocation();

            DoneFetch = false;
        }
コード例 #4
0
        private bool IsIpValid(string role, int locationId)
        {
            var location = LocationServices.GetLocation(locationId);

            if (!string.IsNullOrEmpty(location.StaticIpAddress) &&
                role != "Administrator" &&
                role != "Manager" &&
                !HttpContext.Request.IsLocal &&
                location.StaticIpAddress != HttpContext.Request.UserHostAddress)
            {
                return(false);
            }
            return(true);
        }
コード例 #5
0
        public ActionResult NewVehicle()
        {
            var model = new NewInvoiceModel();

            var location = LocationServices.GetLocation(base.LocationId);

            if (location.DefaultAccountId != 0)
            {
                var defaultAccount = AccountServices.GetAccount(location.DefaultAccountId);
                model.AccountName = defaultAccount.Name;
                model.AccountId   = defaultAccount.Id;
            }

            ViewBag.AccountTypes = AccountTypeServices.GetAccountTypes(false, model.AccountTypeId);

            return(View("NewVehicle", model));
        }
コード例 #6
0
        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));
            }
        }
コード例 #7
0
        protected async override Task OnInitializedAsync()
        {
            int.TryParse(Id, out int LocationId);

            if (LocationId != 0)
            {
                Location = await LocationServices.GetLocation(int.Parse(Id));

                HeaderText = "Edit Library";
            }
            else
            {
                Location = new Location
                {
                    CityName    = "",
                    LibraryName = ""
                };
                HeaderText = "Add Library";
            }
            Mapper.Map(Location, EditLocationModel);
        }
コード例 #8
0
        /// <summary>
        /// "SAVE" CLICK EVENT
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void btnSave_Clicked(object sender, EventArgs e)
        {
            var location = await LocationServices.GetLocation();

            double?longitude = null;
            double?latitude  = null;

            if (location != null)
            {
                longitude = location.Longitude;
                latitude  = location.Latitude;
            }

            Observation newObs = new Observation()
            {
                guid      = Guid.NewGuid(),
                user_id   = 1,
                location  = txtLocation.Text,
                species   = pSpecies.SelectedItem.ToString(),
                notes     = txtNotes.Text,
                photo     = photo,
                approved  = false,
                active    = true,
                longitude = longitude,
                latitude  = latitude
            };

            await App.Database.SaveItemAsync(newObs);

            if (DependencyService.Get <INetworkAvailable>().IsNetworkAvailable())
            {
                await Task.Run(() => new ApiServices().SaveObservation(newObs, token));
            }

            await DisplayAlert("Observation", "Addded successfully!", "OK");

            Application.Current.MainPage = new HomePage();
        }