public async Task <IActionResult> Create([Bind("OrderId,StoreId,UserId,TotalCost,OrderTimestamp,PizzaType,PizzaSize,PizzaCrust")] Orders orders)
        {
            //PizzasSold newPizza = new PizzasSold();
            PizzaSold newPizza = new PizzaSold();

            if (ModelState.IsValid)
            {
                //ViewData["StoreId"] = new SelectList(_context.Stores, "StoreLocation", "StoreLocation", orders.StoreId);
                //ViewData["UserId"] = new SelectList(_context.Users, "UserId", "UserName", orders.UserId);
                //ViewData["PizzaType"] = new SelectList(_context.PizzasSold, "PresetId", "PresetName", newPizza.PizzaName);
                //ViewData["PizzaSize"] = new SelectList(_context.Sizes, "SizeId", "SizeName", newPizza.PizzaSize);
                //ViewData["PizzaCrust"] = new SelectList(_context.CrustTypes, "CrustId", "CrustName", newPizza.PizzaCrust);

                //newPizza.OrderId = orders.OrderId;

                //orders.PizzasSold.Add(newPizza);
                //orders.TotalCost += newPizza.TotalCost;

                _context.Add(orders);
                _context.Add(Mapper.MapPizzaSold(newPizza));

                //orders.PizzasSold.Add(Mapper.MapPizzaSold(ModelState));

                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["StoreId"]    = new SelectList(_context.Stores, "StoreLocation", "StoreLocation", orders.Store.StoreId);
            ViewData["UserId"]     = new SelectList(_context.Users, "UserId", "UserName", orders.UserId);
            ViewData["PizzaType"]  = new SelectList(_context.PizzasSold, "PresetId", "PresetName", newPizza.PizzaName);
            ViewData["PizzaSize"]  = new SelectList(_context.Sizes, "SizeId", "SizeName", newPizza.PizzaSize);
            ViewData["PizzaCrust"] = new SelectList(_context.CrustTypes, "CrustId", "CrustName", newPizza.PizzaCrust);

            //newPizza.Order = orders;
            //newPizza.OrderId = orders.OrderId;

            //orders.PizzasSold.Add(Mapper.MapPizzaSold(newPizza));
            //orders.TotalCost += newPizza.TotalCost;

            return(View(orders));
        }
Beispiel #2
0
        public domain.User CreateUser(string email)
        {
            var entUser = new User();

            domain.User newUser = new domain.User();
            entUser.Email = email;
            newUser.Email = email;

            _db.Add(entUser);
            _db.SaveChanges();
            newUser.Id = entUser.UserId;

            return(newUser);
        }
Beispiel #3
0
        public async Task <IActionResult> Create([Bind("OrderId,PizzaName,PizzaSize,PizzaCrust,TotalCost,PizzaId")] PizzasSold pizzasSold)
        {
            if (ModelState.IsValid)
            {
                _context.Add(pizzasSold);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            //ViewData["OrderId"] = new SelectList(_context.Orders, "OrderId", "OrderId", pizzasSold.OrderId);
            ViewData["PizzaName"]  = new SelectList(_context.PresetPizzas, "PresetName", "PresetName", pizzasSold.PizzaName);
            ViewData["PizzaCrust"] = new SelectList(_context.CrustTypes, "CrustId", "CrustName", pizzasSold.PizzaCrust);
            ViewData["PizzaSize"]  = new SelectList(_context.Sizes, "SizeId", "SizeName", pizzasSold.PizzaSize);
            return(View(pizzasSold));
        }
Beispiel #4
0
 public void Add(Domain.Abstracts.ASize t)
 {
     context.Add(mapper.Map(t, context));
     context.SaveChanges();
     //context.ChangeTracker.Clear();
 }
Beispiel #5
0
 public void Add(AStore t)
 {
     context.Add(mapper.Map(t, context));
     context.SaveChanges();
     //context.ChangeTracker.Clear();
 }
Beispiel #6
0
 public void AddAccount(Library.Models.Account account)
 {
     Entities.Account newAccount = Mapper.Map(account);
     _dbContext.Add(newAccount);
 }
Beispiel #7
0
 public void AddOrder(Library.Models.UserOrder order)
 {
     Entities.UserOrder _order = Mapper.Map(order);
     _dbContext.Add(_order);
 }
 public bool Post(Order order)
 {
     _db.Add(order);
     return(_db.SaveChanges() == 1);
 }