Esempio n. 1
0
        public ActionResult DeleteConfirmed(int id)
        {
            CampingPlace campingPlace = db.CampingPlaces.Find(id);

            db.CampingPlaces.Remove(campingPlace);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Esempio n. 2
0
        private async void ExecuteSave(object obj)
        {
            var   store = AppStore.Instance;
            Place tmp   = null;

            switch (Type)
            {
            case PlaceType.CampingPlace:
                tmp = new CampingPlace();
                break;

            case PlaceType.Hotel:
                tmp = new Hotel();
                break;

            case PlaceType.MotorhomePlace:
                tmp = new MotorhomePlace();
                break;

            case PlaceType.Restaurant:
                tmp = new Restaurant();
                break;

            case PlaceType.Poi:
                tmp = new Poi();
                break;
            }

            tmp.Latitude    = Latitude;
            tmp.Longitude   = Longitude;
            tmp.Rating      = Rating;
            tmp.Altitude    = Altitude;
            tmp.Created     = DateTimeOffset.Now;
            tmp.Description = Description;
            tmp.Name        = Name;
            tmp.PlaceId     = Guid.NewGuid();
            tmp.Trip        = store.CurrentTrip;
            tmp.TripId      = store.CurrentTrip.TripId;

            var trips   = store.User.Trips;
            var tripIdx = trips.IndexOf(store.CurrentTrip);

            // Add new Place to local Collection
            store.User.Trips[tripIdx].Places.Add(tmp);

            // Save to CloudStore
            var tmpPlace = await PlaceStore.AddItemAsync(tmp);

            if (tmpPlace != null)
            {
                SavePlaceSuccessCallback?.Invoke(true);
            }
            else
            {
                SavePlaceSuccessCallback?.Invoke(false);
            }
        }
Esempio n. 3
0
 public ActionResult Edit([Bind(Include = "Id,Name,Latitude,Longitude")] CampingPlace campingPlace)
 {
     if (ModelState.IsValid)
     {
         db.Entry(campingPlace).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(campingPlace));
 }
Esempio n. 4
0
        public ActionResult Create([Bind(Include = "Id,Name,Latitude,Longitude")] CampingPlace campingPlace)
        {
            if (ModelState.IsValid)
            {
                db.CampingPlaces.Add(campingPlace);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(campingPlace));
        }
Esempio n. 5
0
        // GET: CampingPlaces/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            CampingPlace campingPlace = db.CampingPlaces.Find(id);

            if (campingPlace == null)
            {
                return(HttpNotFound());
            }
            return(View(campingPlace));
        }
Esempio n. 6
0
        public MyListViewModel()
        {
            CampingPlace c1 = new CampingPlace {
                Id = 1, Name = "Søborg Camping", City = "Søborg"
            };
            CampingPlace c2 = new CampingPlace {
                Id = 2, Name = "Viborg Camping", City = "Viborg"
            };
            CampingPlace c3 = new CampingPlace {
                Id = 3, Name = "Herning Camping", City = "Herning"
            };
            CampingPlace c4 = new CampingPlace {
                Id = 4, Name = "Aalborg Camping", City = "Aalborg"
            };

            _campingPlaces = new List <CampingPlace>();
            _campingPlaces.Add(c1);
            _campingPlaces.Add(c2);
            _campingPlaces.Add(c3);
            _campingPlaces.Add(c4);
        }