Пример #1
0
        public ActionResult Create([Bind(Include = "rg_name")] RunningGroup runningGroup)
        {
            if (ModelState.IsValid)
            {
                db.RunningGroups.Add(runningGroup);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(runningGroup));
        }
Пример #2
0
        public ActionResult Create([Bind(Include = "r_id,r_distance,r_duration,r_date,r_datfeel")] Run run)
        {
            Console.WriteLine("CREATE RUN");
            if (ModelState.IsValid)
            {
                Console.WriteLine("Should add.");
                run.r_user = User.Identity.Name;
                db.Runs.Add(run);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.r_datfeel = new SelectList(db.FeelingAfterRuns, "far_id", "far_datfeel", run.r_datfeel);
            ViewBag.r_user    = new SelectList(db.Users, "u_username", "u_username", run.r_user);
            return(View(run));
        }
Пример #3
0
        public ActionResult LeaveGroup()
        {
            var result = entities.Users.SingleOrDefault(b => b.u_username == User.Identity.Name);

            result.u_runninggroup = null;
            entities.SaveChanges();
            return(RedirectToAction("Index", "Home"));
        }
Пример #4
0
        public async Task <ActionResult> Register(RegisterViewModel model)
        {
            if (ModelState.IsValid)
            {
                Console.WriteLine("--- IMPORTANTT ---");
                Console.WriteLine(model.Password);
                entities.Users.Add(new ViennaRuns.User {
                    u_username = model.Username, u_password = model.Password, u_weight = model.Weight
                });
                entities.SaveChanges();
                FormsAuthentication.SetAuthCookie(model.Username, false);
                return(RedirectToAction("Index", "Home"));
            }

            // If we got this far, something failed, redisplay form
            return(View(model));
        }