public void Insert(SkiResort SkiResort)
        {
            SkiResort.Id = NextIdValue();
            _skiResorts.Add(SkiResort);

            Save();
        }
Exemplo n.º 2
0
        public ActionResult DeleteConfirmed(int id)
        {
            SkiResort skiResort = db.SkiResorts.Find(id);

            db.SkiResorts.Remove(skiResort);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Exemplo n.º 3
0
 public ActionResult Edit([Bind(Include = "Id,Name,City,State,Address,Zip,SnowFall,NumberOfRuns,NumberOfLifts,Elevation")] SkiResort skiResort)
 {
     if (ModelState.IsValid)
     {
         db.Entry(skiResort).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(skiResort));
 }
        public SkiResort SelectOne(int id)
        {
            //SkiResort selectedSkiResort =
            //(from SkiResort in _skiResorts
            // where SkiResort.Id == id
            // select SkiResort).FirstOrDefault();

            SkiResort selectedSkiResort = _skiResorts.Where(p => p.Id == id).FirstOrDefault();

            return(selectedSkiResort);
        }
        public ActionResult Delete(int id)
        {
            SkiResortRepository srRepository = new SkiResortRepository();
            SkiResort           skiResort    = new SkiResort();

            using (srRepository)
            {
                skiResort = srRepository.SelectOne(id);
            }

            return(View(skiResort));
        }
        public void Update(SkiResort UpdateSkiResort)
        {
            var oldSkiResort = _skiResorts.Where(b => b.Id == UpdateSkiResort.Id).FirstOrDefault();

            if (oldSkiResort != null)
            {
                _skiResorts.Remove(oldSkiResort);
                _skiResorts.Add(UpdateSkiResort);
            }

            Save();
        }
Exemplo n.º 7
0
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            SkiResort skiResort = db.SkiResorts.Find(id);

            if (skiResort == null)
            {
                return(HttpNotFound());
            }
            return(View(skiResort));
        }
        public ActionResult Delete(int id, SkiResort skiResort)
        {
            try
            {
                SkiResortRepository srRepository = new SkiResortRepository();

                using (srRepository)
                {
                    srRepository.Delete(id);
                }

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
        public ActionResult Edit(SkiResort skiResort)
        {
            try
            {
                SkiResortRepository srRepository = new SkiResortRepository();

                using (srRepository)
                {
                    srRepository.Update(skiResort);
                }

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
        public ActionResult Create(SkiResort skiResortCollection)
        {
            try
            {
                SkiResortRepository Repository = new SkiResortRepository();

                using (Repository)
                {
                    Repository.Insert(skiResortCollection);
                }

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }