Esempio n. 1
0
        public void TestDb()
        {
            var context = new FoodOrderContext().CreateDbContext(null);

            context.WeekDays.Add(new WeekDay {
                Name = "Wd"
            });
            context.SaveChanges();
            var t = context.WeekDays.FirstOrDefault(x => x.Name == "Wd");

            Assert.Equal(t.Name, "Wd");

            context.Remove(t);
            context.SaveChanges();
            var w = context.WeekDays.FirstOrDefault(x => x.Name == "Wd");

            Assert.Null(w);
        }
Esempio n. 2
0
        public ActionResult Register(FormCollection collection)
        {
            bool filledUp = true;

            foreach (string key in collection.AllKeys)
            {
                if (key.StartsWith("_"))
                {
                    continue;
                }

                /*
                 * Response.Write("Key = " + key + " , ");
                 * Response.Write("Value = " + collection[key]);
                 * Response.Write("<br/>");
                 */
                if (collection[key] == "")
                {
                    filledUp = false;
                }
            }

            if (filledUp)
            {
                Registration p = new Registration
                {
                    CustomerName    = collection["CustomerName"],
                    Phonenumber     = collection["Phonenumber"],
                    Email           = collection["Email"],
                    DeliveryAddress = collection["DeliveryAddress"],
                    UserName        = collection["UserName"],
                    Password        = collection["Password"]
                };

                FoodOrderContext foodOrderContext = new FoodOrderContext();
                foodOrderContext.Registrations.Add(p);
                foodOrderContext.SaveChanges();

                Session["UserId"]   = p.CustomerID.ToString();
                Session["UserName"] = p.CustomerName.ToString();
                return(View("Profile"));
            }

            return(View());
        }
Esempio n. 3
0
 public void Save()
 {
     _context.SaveChanges();
 }