Ejemplo n.º 1
0
        public IActionResult Update(int id)
        {
            // TODO P09 Task 3-3: Assign dbs to _dbContext.ShirtOrder
            DbSet <ShirtOrder> dbs = _dbContext.ShirtOrder;

            // TODO P09 Task 3-4: User dbs.Where and FirstOrDefault methods to retrieve the targetted ShirtOrder
            ShirtOrder tOrder = dbs.Where(mo => mo.Id == id).FirstOrDefault();

            if (tOrder != null)
            {
                DbSet <Pokedex> dbsPoke  = _dbContext.Pokedex;
                var             lstPokes =
                    dbsPoke.ToList <Pokedex>()
                    .OrderBy(p => p.Name)
                    .Select(
                        p =>
                {
                    dynamic d = new ExpandoObject();
                    d.value   = p.Id;
                    d.text    = p.Name;
                    return(d);
                }
                        )
                    .ToList <dynamic>();
                ViewData["pokes"] = lstPokes;

                return(View(tOrder));
            }
            else
            {
                TempData["Msg"] = "Shirt order not found!";
                return(RedirectToAction("Index"));
            }
        }
Ejemplo n.º 2
0
        public IActionResult Update(int id)
        {
            DbSet <ShirtOrder> dbs    = _dbContext.ShirtOrder;
            ShirtOrder         tOrder = dbs.Where(mo => mo.Id == id).FirstOrDefault();

            if (tOrder != null)
            {
                var lstPokes =
                    _dbContext.Pokedex
                    .ToList <Pokedex>()
                    .OrderBy(p => p.Name)
                    .Select(
                        p =>
                {
                    dynamic d = new ExpandoObject();
                    d.value   = p.Id;
                    d.text    = p.Name;
                    return(d);
                }
                        )
                    .ToList <dynamic>();
                ViewData["pokes"] = lstPokes;

                return(View(tOrder));
            }
            else
            {
                TempData["Msg"] = "Shirt order not found!";
                return(RedirectToAction("Index"));
            }
        }
Ejemplo n.º 3
0
        public IActionResult Create(ShirtOrder shirtOrder)
        {
            if (ModelState.IsValid)
            {
                _dbContext.ShirtOrder.Add(shirtOrder);
                _dbContext.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(shirtOrder));
        }
Ejemplo n.º 4
0
        public async Task <IActionResult> PostShirtOrder([FromBody] ShirtOrder shirtOrder)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.ShirtOrders.Add(shirtOrder);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetShirtOrder", new { id = shirtOrder.ShirtOrderID }, shirtOrder));
        }
Ejemplo n.º 5
0
        public IActionResult LoadShirt(string color, int pokedexid)
        {
            // TODO P10 Task 3-1 Complete the following code to create a new MugOrder and assign the pokedexid and color to the model properties
            //MugOrder model = null; // this line needs to be modified to achieve Task 3-1
            ShirtOrder model = new ShirtOrder();

            model.Color     = color;
            model.PokedexId = pokedexid;

            // TODO P10 Task 3-2 Use PartialView method to return _ShowMug partial view and pass model object as the model
            //return null; // this line needs to be modified to achieve Task 3-2
            return(PartialView("_ShowShirt", model));
        }
Ejemplo n.º 6
0
        }//end AddShirtDetailsbutton_Click

        //Test=================================

        private void Calculatebutton_Click(object sender, EventArgs e)
        {
            //for(int i; i<1; i++)
            //{
            //    foreach(ItemBase item in ShirtDetailsAddlistBox.Items)
            //    {

            //    }
            //}//end for loop

            decimal taxF;
            decimal paidUFForm;
            decimal marginL;
            decimal laborL;



            decimal.TryParse(MarginPercentageSelectorcomboBox.Text, out marginL);
            decimal.TryParse(AmountPaidtextBox.Text, out paidUFForm);
            decimal.TryParse(TaxAmounttextBox.Text, out taxF);
            decimal.TryParse(LaborPercentagecomboBox.Text, out laborL);
            DateTime   dateDue      = DueDateDateTimePicker.Value;
            ShirtOrder CurrentOrder = new ShirtOrder("ItemID", "Shirt Order", "Material", /*"PricePerScreen"*/ 1.04M, /*screens*/ 4,
                                                     "ClientID", "employeeID", DateTime.Today, DueDateDateTimePicker.Value, OrderDetTextBox.Text,
                                                     taxF, paidUFForm, marginL, laborL);



            foreach (ItemBase i in ItemListlistBox.Items)
            {
                decimal RunningTotal = 0;
                CurrentOrder.AddItemsOrderedItemsList(i);
                foreach (int n in ShirtItemQtyListBox.Items)
                {
                    //money = RunningTotal +  n * i.UnitPrice;
                }
            }//end foreach

            string strMoney;

            //strMoney = money.ToString();
            //TotalQuotetextBox.Text = strMoney;
            for (int i = 0; i > CurrentOrder.OrderedItemsListCount(); i++)
            {
            }
            TotalQuotetextBox.Text = "Total";
        }//end CalculateButton_Click
Ejemplo n.º 7
0
        }//end AddShirtDetailsButton Handler(Click)

        //Test=================================

        private void Calculatebutton_Click(object sender, EventArgs e)
        {
            if (amountCollected > 0)
            {
                amountCollected = amountCollected * 1;
            }
            else
            {
                decimal.TryParse(AmountPaidtextBox.Text, out amountCollected);
            }//end IF

            ShirtOrder currentOrder = new ShirtOrder("1243431", "Shirt Order", "100% Cotton", 5, screens, tag, "00090000C", "00090000E",
                                                     orderTimeClock, dueDateSelector, descriptionNotes, taxForm, amountCollected, 5, itemsPurchased,
                                                     margin, labor);

            ObjectShirtOrderCreator();
            TotalQuotetextBox.Text = currentOrder.OrderTotal().ToString();
        }
Ejemplo n.º 8
0
        public IActionResult Update(ShirtOrder shirtOrder)
        {
            if (ModelState.IsValid)
            {
                // TODO P09 Task 3-5: Repeat task 3-3 and 3-4
                DbSet <ShirtOrder> dbs    = _dbContext.ShirtOrder;
                ShirtOrder         tOrder = dbs.Where(mo => mo.Id == shirtOrder.Id).FirstOrDefault();

                if (tOrder != null)
                {
                    // TODO P09 Task 3-6: Assign ShirtOrder's property values to tOrder's properties
                    // Note: Assign current login user's Id to CreatedBy column
                    tOrder.Name          = shirtOrder.Name;
                    tOrder.Qty           = shirtOrder.Qty;
                    tOrder.Price         = shirtOrder.Price;
                    tOrder.Color         = shirtOrder.Color;             // this is done for you
                    tOrder.PokedexId     = shirtOrder.PokedexId;
                    tOrder.FrontPosition = shirtOrder.FrontPosition;
                    // TODO P09 Task 3-7: Update database using _dbContext and display appropriate message
                    if (_dbContext.SaveChanges() == 1)
                    {
                        TempData["Msg"] = "Shirt order updated!";
                    }
                    else
                    {
                        TempData["Msg"] = "Failed to update database!";
                    }
                }
                else
                {
                    TempData["Msg"] = "Shirt order not found!";
                    return(RedirectToAction("Index"));
                }
            }
            else
            {
                TempData["Msg"] = "Invalid information entered";
            }
            return(RedirectToAction("Index"));
        }
Ejemplo n.º 9
0
 public IActionResult Create(ShirtOrder shirtOrder)
 {
     if (ModelState.IsValid)
     {
         DbSet <ShirtOrder> dbs = _dbContext.ShirtOrder;
         shirtOrder.CreatedBy = User.FindFirst(ClaimTypes.NameIdentifier).Value;
         dbs.Add(shirtOrder);
         if (_dbContext.SaveChanges() == 1)
         {
             TempData["Msg"] = "New order added!";
         }
         else
         {
             TempData["Msg"] = "Failed to update database!";
         }
     }
     else
     {
         TempData["Msg"] = "Invalid information entered";
     }
     return(RedirectToAction("Index"));
 }
Ejemplo n.º 10
0
        public IActionResult Update(ShirtOrder shirtOrder)
        {
            if (ModelState.IsValid)
            {
                DbSet <ShirtOrder> dbs    = _dbContext.ShirtOrder;
                ShirtOrder         tOrder = dbs.Where(mo => mo.Id == shirtOrder.Id).FirstOrDefault();

                if (tOrder != null)
                {
                    tOrder.Name          = shirtOrder.Name;
                    tOrder.Color         = shirtOrder.Color;
                    tOrder.PokedexId     = shirtOrder.PokedexId;
                    tOrder.Qty           = shirtOrder.Qty;
                    tOrder.Price         = shirtOrder.Price;
                    tOrder.FrontPosition = shirtOrder.FrontPosition;

                    if (_dbContext.SaveChanges() == 1)
                    {
                        TempData["Msg"] = "Shirt order updated!";
                    }
                    else
                    {
                        TempData["Msg"] = "Failed to update database!";
                    }
                }
                else
                {
                    TempData["Msg"] = "Shirt order not found!";
                    return(RedirectToAction("Index"));
                }
            }
            else
            {
                TempData["Msg"] = "Invalid information entered";
            }
            return(RedirectToAction("Index"));
        }
Ejemplo n.º 11
0
 //
 public void ObjectShirtOrderCreator()
 {
     ShirtOrder currentOrder = new ShirtOrder("1243431", "Shirt Order", "100% Cotton", 5, screens, tag, "00090000C", "00090000E",
                                              orderTimeClock, dueDateSelector, descriptionNotes, taxForm, amountCollected, 5, itemsPurchased,
                                              margin, labor);
 }