public ActionResult Create(String name, String description, String price, bool isFeatured = false)
        {
            ScarfItem scarf = new ScarfItem();

                bool error = false;

                if (name == null || name.Equals(""))
                {
                    Console.Out.WriteLine("name is null or empty");
                    ViewBag.ErrorName = "name is required";
                    error = true;
                }
                else
                {
                    scarf.name = name;
                }
                if (description == null || description.Equals(""))
                {
                    ViewBag.ErrorDescription = "description is required"; error = true;
                }
                else
                {
                    scarf.description = description;
                }
                if (price == null || price.Equals(""))
                {
                    ViewBag.ErrorPrice = "price is required"; error = true;
                }
                else
                {
                    try
                    {
                        scarf.price = decimal.Parse(price);
                    }
                    catch (Exception e)
                    {
                        ViewBag.ErrorPrice = e.Message;
                        error = true;
                    }
                }
                scarf.isFeatured = isFeatured;
                if (error)
                {
                    ViewBag.Error = "Please fill out all required fields";
                    return View(scarf);
                }
                else
                {
                    // Insert the data and return to the Index view
                    service.addScarf(scarf);
                    IEnumerable<ScarfItem> scarves = service.getAllScarves();
                    return View("Index", scarves);
                }
        }
 public void addScarf(ScarfItem s)
 {
     _scarfRepo.add(s);
 }
        public ActionResult Create(String name, String description, String price)
        {
            Customer c = getCurrentUser();
            if (c != null && c.isAdmin)
            {
                ScarfItem scarf = new ScarfItem();

                bool error = false;

                if (name == null || name.Equals(""))
                {
                    Console.Out.WriteLine("name is null or empty");
                    ViewBag.ErrorName = "name is required";
                    error = true;
                }
                else
                {
                    scarf.name = name;
                }
                if (description == null || description.Equals(""))
                {
                    ViewBag.ErrorDescription = "description is required"; error = true;
                }
                else
                {
                    scarf.description = description;
                }
                if (price == null || price.Equals(""))
                {
                    ViewBag.ErrorPrice = "price is required"; error = true;
                }
                else
                {
                    try
                    {
                        scarf.price = decimal.Parse(price);
                    }
                    catch (Exception e)
                    {
                        ViewBag.ErrorPrice = e.Message;
                        error = true;
                    }
                }
                if (error)
                {
                    ViewBag.Error = "Please fill out all required fields";
                    return View(scarf);
                }
                else
                {
                    // Insert the data and return to the Index view
                    service.addScarf(scarf);

                    IEnumerable<ScarfItem> scarves = service.getAllScarves();
                    Customer customer = getCurrentUser();
                    var CandP = new CustomerAndProducts();
                    CandP.Customer = customer;
                    CandP.Cart = service.getCustomerCart(customer);
                    CandP.Scarves = scarves;

                    return View("Index", CandP);
                }
            }
            else
            {
                TempData["GlobalError"] = "You are not Authorized to access the requested page";
                return RedirectToAction("Index", "Home");
            }
        }
 public void updateScarf(ScarfItem scarf)
 {
     _scarfRepo.update(scarf);
 }