Ejemplo n.º 1
0
        public ActionResult Create(School school)
        {
            if (ModelState.IsValid)
            {
                db.Schools.Add(school);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(school));
        }
        public ActionResult Create(Activity activity)
        {
            if (ModelState.IsValid)
            {
                db.Activities.Add(activity);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(activity));
        }
        public ActionResult Create(Category category)
        {
            if (ModelState.IsValid)
            {
                db.Categories.Add(category);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(category));
        }
Ejemplo n.º 4
0
 public ActionResult Edit(Order order)
 {
     if (ModelState.IsValid)
     {
         db.Entry(order).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.UserId = new SelectList(db.UserProfiles, "UserId", "UserName", order.UserId);
     return(View(order));
 }
        public ActionResult Create(Product product)
        {
            if (ModelState.IsValid)
            {
                db.Products.Add(product);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.CategoryId = new SelectList(db.Categories, "CategoryId", "CategoryName", product.CategoryId);
            return(View(product));
        }
Ejemplo n.º 6
0
 public ActionResult Edit(OrderDetail orderdetail)
 {
     if (ModelState.IsValid)
     {
         db.Entry(orderdetail).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.ProductId = new SelectList(db.Products, "ProductId", "ProductName", orderdetail.ProductId);
     ViewBag.OrderId   = new SelectList(db.Orders, "OrderId", "UserName", orderdetail.OrderId);
     return(View(orderdetail));
 }
Ejemplo n.º 7
0
        public ActionResult Create(UserProfile userprofile)
        {
            if (ModelState.IsValid)
            {
                db.UserProfiles.Add(userprofile);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.SchoolId = new SelectList(db.Schools, "SchoolId", "SchoolName", userprofile.SchoolId);
            return(View(userprofile));
        }
        public ActionResult Create(int[] userId, int[] activityId, DateTime activityDate)
        {
            if (ModelState.IsValid)
            {
                foreach (int i in userId)
                {
                    UserProfile updUserProfile = db.UserProfiles.Find(i);
                    foreach (int x in activityId)
                    {
                        Activity act    = db.Activities.Find(x);
                        int      points = act.PointValue;
                        updUserProfile.PointTotal           += points;
                        updUserProfile.CumulativePointTotal += points;
                        var activityTransaction = new ActivityTransaction
                        {
                            UserId       = i,
                            ActivityDate = activityDate,
                            ActivityId   = x
                        };
                        db.ActivityTransactions.Add(activityTransaction);
                        db.SaveChanges();
                    }
                }
                //Fetch User Profile
                //UserProfile updUserProfile = db.UserProfiles.Find(activitytransaction.UserId);
                //Fetch Activity
                // Activity act = db.Activities.Find(activitytransaction.ActivityId);
                //Fetch point value for completed activity
                //int points = act.PointValue;
                //Add Points
                //updUserProfile.PointTotal += points;
                //updUserProfile.CumulativePointTotal += points;

                //db.ActivityTransactions.Add(activitytransaction);
                // db.SaveChanges();

                //AddStudentPoints(updUserProfile, points);

                return(RedirectToAction("Index"));
            }
            var usernames    = Roles.GetUsersInRole("Student");
            var studentUsers = db.UserProfiles
                               .Where(x => usernames.Contains(x.UserName)).ToList();

            ViewBag.UserId     = new MultiSelectList(studentUsers, "UserId", "UserName");
            ViewBag.ActivityId = new MultiSelectList(db.Activities, "ActivityId", "ActivityName");
            return(RedirectToAction("Index"));
        }
        //
        // POST: /Checkout/Confirmation

        public ActionResult CompletingResult()
        {
            int         userId = Convert.ToInt32(Membership.GetUser().ProviderUserKey.ToString());
            UserProfile user   = db.UserProfiles.Find(userId);
            var         cart   = ShoppingCart.GetCart(this.HttpContext);

            var order = new Order();

            TryUpdateModel(order);

            order.UserId       = userId;
            order.UserName     = User.Identity.Name;
            order.OrderDate    = DateTime.Now;
            order.UserProfiles = user;
            order.FirstName    = user.FirstName;
            order.LastName     = user.LastName;
            order.IsFulfilled  = false;

            //Save Order
            db.Orders.Add(order);
            user.PointTotal -= cart.GetTotal();
            db.SaveChanges();
            //Process Order
            cart.CreateOrder(order);

            return(RedirectToAction("Complete", new { id = order.OrderId }));
        }
Ejemplo n.º 10
0
 public ActionResult Edit(FrontPage frontpage)
 {
     if (ModelState.IsValid)
     {
         db.Entry(frontpage).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(frontpage));
 }
Ejemplo n.º 11
0
        public ActionResult ExternalLoginConfirmation(RegisterExternalLoginModel model, string returnUrl)
        {
            string provider       = null;
            string providerUserId = null;

            if (User.Identity.IsAuthenticated || !OAuthWebSecurity.TryDeserializeProviderUserId(model.ExternalLoginData, out provider, out providerUserId))
            {
                return(RedirectToAction("Manage"));
            }

            if (ModelState.IsValid)
            {
                // Insert a new user into the database
                using (var db = new Kickoff4KidsDb())
                {
                    UserProfile user = db.UserProfiles.FirstOrDefault(u => u.UserName.ToLower() == model.UserName.ToLower());
                    // Check if user already exists
                    if (user == null)
                    {
                        // Insert name into the profile table
                        db.UserProfiles.Add(new UserProfile {
                            UserName = model.UserName
                        });
                        db.SaveChanges();

                        OAuthWebSecurity.CreateOrUpdateAccount(provider, providerUserId, model.UserName);
                        OAuthWebSecurity.Login(provider, providerUserId, createPersistentCookie: false);

                        return(RedirectToLocal(returnUrl));
                    }
                    else
                    {
                        ModelState.AddModelError("UserName", "User name already exists. Please enter a different user name.");
                    }
                }
            }

            ViewBag.ProviderDisplayName = OAuthWebSecurity.GetOAuthClientData(provider).DisplayName;
            ViewBag.ReturnUrl           = returnUrl;
            return(View(model));
        }