public JsonResult UpdateLayawayItemQuantity(string Id, int quantity)
        {
            ILayawayDataService dataService = new LayawayDataService();
            object updateResult             = dataService.UpdateLayawayItemQuantity(layawayItemContext, Id, quantity);

            return(Json(updateResult, JsonRequestBehavior.AllowGet));
        }
        public JsonResult DeleteLayawayItem(string Id)
        {
            ILayawayDataService dataService = new LayawayDataService();
            object deleteResult             = dataService.RemoveItemFromLayaway(layawayItemContext, Id);

            return(Json(deleteResult, JsonRequestBehavior.AllowGet));    // deleteResult: {Successful = value, Message = vlue}
        }
        public JsonResult UpdateLayawayItem(string Id, string productDescription, int quantity, decimal price)
        {
            ILayawayDataService dataService = new LayawayDataService();
            object updateResult             = dataService.UpdateLayawayItem(layawayItemContext, Id, productDescription, quantity, price);

            return(Json(updateResult, JsonRequestBehavior.AllowGet));
        }
        public JsonResult AddLayawayItem(string data)
        {
            ILayawayDataService dataService = new LayawayDataService();
            object addResult = dataService.AddItemToLayaway(layawayItemContext, data);

            return(Json(addResult, JsonRequestBehavior.AllowGet));
        }
        public JsonResult UpdateLayaway(string data)
        {
            ILayawayDataService dataService = new LayawayDataService();
            object updateResult             = dataService.UpdateLayaway(layawayContext, data);

            return(Json(updateResult, JsonRequestBehavior.AllowGet));
        }
        public JsonResult DeleteLayaway(string Id)
        {
            ILayawayDataService dataService = new LayawayDataService();
            object deleteResult             = dataService.DeleteLayaway(layawayContext, Id);

            return(Json(deleteResult, JsonRequestBehavior.AllowGet));
        }
        //*******************************************************************************
        //                              Layaway Methods
        //*******************************************************************************
        public JsonResult AddLayaway(string customerId)
        {
            ILayawayDataService dataService = new LayawayDataService();
            object inserResult = dataService.AddLayaway(layawayContext, customerId);

            return(Json(inserResult, JsonRequestBehavior.AllowGet));
        }
        public ActionResult Edit(Customer customer, string Id)
        {
            Customer customerToEdit = customerContext.Find(Id);

            if (customerToEdit == null)
            {
                return(HttpNotFound());
            }
            else
            {
                if (!ModelState.IsValid)
                {
                    // reload ProductList
                    IProductRetrieveService productService = new ProductRetrieveService();
                    customer.ProductList = productService.GetProducts();

                    // reload Layaways
                    ILayawayDataService layawayService = new LayawayDataService();
                    customer.Layaways = layawayService.GetLayaways(Id);

                    return(View(customer));
                }

                customerToEdit.FirstName   = customer.FirstName;
                customerToEdit.LastName    = customer.LastName;
                customerToEdit.Email       = customer.Email;
                customerToEdit.CompanyName = customer.CompanyName;
                customerToEdit.Street      = customer.Street;
                customerToEdit.City        = customer.City;
                customerToEdit.State       = customer.State;
                customerToEdit.ZipCode     = customer.ZipCode;
                customerToEdit.Phone       = customer.Phone;
                customerToEdit.Phone2      = customer.Phone2;
                customerToEdit.Website     = customer.Website;

                customerContext.Commit();
                return(RedirectToAction("Index"));
            }
        }