Example #1
0
 public IActionResult Create(Trail trail)
 {
     System.Console.WriteLine(trail.Name);
     System.Console.WriteLine(trail.Description);
     trailFactory.Add(trail);
     return(RedirectToAction("Index"));
 }
Example #2
0
 public IActionResult Create(Trail trail)
 {
     if (ModelState.IsValid)
     {
         _trailFactory.Add(trail);
         return(RedirectToAction("Trails"));
     }
     return(View("Add"));
 }
Example #3
0
 public IActionResult CreateTrail(Trail form)
 {
     if (tr == null)
     {
         tr = new TrailFactory();
     }
     tr.Add(form);
     return(RedirectToAction("Index"));
 }
Example #4
0
 public IActionResult New(Trail form)
 {
     if (ModelState.IsValid)
     {
         _TrailFactory.Add(form);
         return(RedirectToAction("Index"));
     }
     return(View("NewForm"));
 }
 public IActionResult Add(Trail trail)
 {
     if (!ModelState.IsValid)
     {
         return(View("New"));
     }
     trailFactory.Add(trail);
     return(RedirectToAction("Index"));
 }
Example #6
0
 public IActionResult Process(Trail data)
 {
     if (ModelState.IsValid)
     {
         trailFactory.Add(data);
         return(RedirectToAction("Index"));
     }
     return(View("NewTrail"));
 }
Example #7
0
 public IActionResult CreateTrail(Trail trail)
 {
     if (ModelState.IsValid)
     {
         _trailFactory.Add(trail);
         return(RedirectToAction("Index"));
     }
     return(View("NewTrail"));
 }
 public IActionResult CreateTrail(Trail trail)
 {
     if (ModelState.IsValid)
     {
         trailFactory.Add(trail);
         // return Json(trail); // For debugging purposes! No return required.
     }
     return(View("NewTrail"));
 }
Example #9
0
 public IActionResult AddTrail(Trail newTrail)
 {
     if (ModelState.IsValid)
     {
         trailFactory.Add(newTrail);
         return(RedirectToAction("Index"));
     }
     ViewBag.Errors = ModelState.Values; // NEED to add errors to View
     return(View());
 }
Example #10
0
 public IActionResult Add(Trail NewTrail)
 {
     if (ModelState.IsValid)
     {
         trailFactory.Add(NewTrail);
         System.Console.WriteLine("write stuff");
         return(RedirectToAction("Index"));
     }
     return(View("NewTrail"));
 }
Example #11
0
        public IActionResult AddNew(Trail trail)
        {
            if (ModelState.IsValid)
            {
                trailFactory.Add(trail);
                return(RedirectToAction("Index"));
            }

            return(View("AddTrail"));
        }
Example #12
0
 public IActionResult Create(Trail trail)
 {
     TryValidateModel(trail);
     if (ModelState.IsValid)
     {
         trailFactory.Add(trail);
         return(RedirectToAction("Index"));
     }
     return(View("Create"));
 }
Example #13
0
 public IActionResult newTrailCreate(Trail trail)
 {
     System.Console.WriteLine("top of create");
     if (ModelState.IsValid)
     {
         trailFactory.Add(trail);
         System.Console.WriteLine("here");
         return(RedirectToAction("Index"));
     }
     System.Console.WriteLine("bottom of create");
     return(View("newTrail"));
 }
 public IActionResult Create(Trail newTrail)
 {
     if (ModelState.IsValid)
     {
         _trailFactory.Add(newTrail);
         return(RedirectToAction("Index"));
     }
     else
     {
         return(View("NewTrail", newTrail));
     }
 }
 public IActionResult Create(TrailModel submission)
 {
     if (ModelState.IsValid)
     {
         trailFactory.Add(submission);
         return(RedirectToAction("Index"));
     }
     else
     {
         return(View("NewTrail"));
     }
 }
 public IActionResult Create(Trail item)
 {
     if (ModelState.IsValid)
     {
         trailFactory.Add(item);
         return(RedirectToAction("Index"));
     }
     else
     {
         return(View("add", item));
     }
 }
Example #17
0
 public IActionResult Create(Trail newTrail)
 {
     if (ModelState.IsValid)
     {
         trailFactory.Add(newTrail);
         return(Redirect("/"));
     }
     else
     {
         return(View("NewTrail"));
     }
 }
Example #18
0
 public IActionResult ProcessAdd(LostWoods.Models.Trail newTrail)
 {
     if (ModelState.IsValid)
     {
         _trailFactory.Add(newTrail);
         return(RedirectToAction("Index"));
     }
     else
     {
         return(View("NewTrail"));
     }
 }
Example #19
0
        public IActionResult CreateTrail(TrailInfo trailInfo)
        {
            if (ModelState.IsValid)
            {
                trailFactory.Add(trailInfo);

                return(RedirectToAction("Index"));
            }
            else
            {
                return(View("NewTrail"));
            }
        }
Example #20
0
 public IActionResult CreateTrailProcess(Trail newTrail)
 {
     if (ModelState.IsValid)
     {
         trailFactory.Add(newTrail);
         return(RedirectToAction("Index"));
     }
     else
     {
         ViewBag.Errors = "Please fill out the fields completely!";
         return(View("Add"));
     }
 }
Example #21
0
 public IActionResult createTrail(Trail trail)
 {
     TryValidateModel(trail);
     if (ModelState.IsValid)
     {
         trailFactory.Add(trail);
         return(RedirectToAction("Index")); //change RTA to a return view
     }
     else
     {
         return(View("addTrail"));
     }
 }
Example #22
0
        public IActionResult addTrail(Trail trail)
        {
            if (ModelState.IsValid)
            {
                trailFactory.Add(trail);
            }
            var errors = ModelState.Select(x => x.Value.Errors)
                         .Where(y => y.Count > 0)
                         .Select(z => z[0].ErrorMessage.ToString())
                         .ToList();

            TempData["error_list"] = errors;
            return(RedirectToAction("aNewTrail"));
        }
Example #23
0
 public IActionResult Create(Trail Trail)
 {
     if (ModelState.IsValid != true)
     {
         // failed validations
         return(View("New"));
     }
     else
     {
         // add trail to db
         _TrailFactory.Add(Trail);
         return(RedirectToAction("Index"));
     }
 }
Example #24
0
 public IActionResult process(Trail trail)
 {
     if (ModelState.IsValid)
     {
         Console.WriteLine("THERE WERE NO ERRORS!");
         trailFactory.Add(trail);
         return(Redirect("/"));
     }
     else
     {
         Console.WriteLine("THERE WAS ERRORS IN YOUR FORM!");
         return(View("addTrail", trail));
     }
 }
Example #25
0
 public IActionResult AddTrail(TrailViewModel model)
 {
     if (ModelState.IsValid)
     {
         var Trail = new Trail {
             name        = model.name,
             length      = model.length,
             elev_change = model.elev_change,
             longitude   = model.longitude,
             latitude    = model.latitude,
             description = model.description,
         };
         trailFactory.Add(Trail);
         return(RedirectToAction("Index"));
     }
     return(View("AddForm", model));
 }
Example #26
0
 public IActionResult Add(TrailViewModel newTrail)
 {
     if (ModelState.IsValid)
     {
         Trail trail = new Trail {
             Name        = newTrail.Name,
             Description = newTrail.Description,
             Length      = newTrail.Length,
             Elevation   = newTrail.Elevation,
             Latitude    = newTrail.Latitude,
             Longitude   = newTrail.Longitude
         };
         trailFactory.Add(trail);
         return(RedirectToAction("Index"));
     }
     return(View("NewTrail"));
 }
Example #27
0
        public IActionResult Add(RegisterViewModel model)
        {
            if (ModelState.IsValid)
            {
                Trail trail = new Trail {
                    name        = model.name,
                    length      = model.length,
                    description = model.description,
                    elevation   = model.elevation,
                    latitude    = model.latitude,
                    longitude   = model.longitude
                };
                trailfactory.Add(trail);

                return(RedirectToAction("Index"));
            }
            ViewBag.errors = ModelState.Values;
            return(View("New"));
        }
Example #28
0
 public IActionResult AddTrail(Trail t, string NS, string EW)
 {
     if (NS == "S" && t.Latitude > 0)
     {
         t.Latitude = t.Latitude * -1;
     }
     if (EW == "W" && t.Longitude > 0)
     {
         t.Longitude = t.Longitude * -1;
     }
     if (ModelState.IsValid)
     {
         trailFactory.Add(t);
         return(RedirectToAction("Index"));
     }
     else
     {
         return(View("NewTrail"));
     }
 }
Example #29
0
        public IActionResult Store(Trail model)
        {
            if (ModelState.IsValid)
            {
                //List<Dictionary<string, object>> User = _dbConnector.Query($"INSERT INTO users (first_name, last_name, email, password, age) VALUES ('{model.FirstName}', '{model.LastName}', '{model.Email}', '{model.Password}', 0)");
                trailFactory.Add(model);

                return(RedirectToAction("Index"));
            }
            else
            {
                string messages = string.Join("; ", ModelState.Values
                                              .SelectMany(x => x.Errors)
                                              .Select(x => x.ErrorMessage));
                Console.WriteLine(messages);
                HttpContext.Session.SetObjectAsJson("TheList", ModelState.Values);
                return(RedirectToAction("NewTrail"));
            }

            //List<Dictionary<string, object>> Allq = _dbConnector.Query("SELECT * FROM quotes ORDER BY created_at Desc");
        }
Example #30
0
        public IActionResult AddTrail(NewTrailViewModel trail)
        {
            if (ModelState.IsValid)
            {
                Console.WriteLine("ModelState is valid.");
                Trail NewTrail = new Trail
                {
                    TrailName     = trail.TrailName,
                    Description   = trail.Description,
                    TrailLength   = trail.TrailLength,
                    ElevationGain = trail.ElevationGain,
                    Lattitude     = trail.Lattitude,
                    Longitude     = trail.Longitude
                };

                trailFactory.Add(NewTrail);
            }
            else
            {
                ViewBag.errors = ModelState.Values;
                return(View());
            }
            return(RedirectToAction("Index"));
        }