コード例 #1
0
        public ActionResult Manage()
        {
            int c = Convert.ToInt32(Session["CustomerId"]);

            ServiceReference.Service1Client order = new ServiceReference.Service1Client();
            var            o      = order.GetOrder(c);
            var            od     = new List <ServiceReference.OrderDetail>();
            var            p      = new ServiceReference.Product();
            List <decimal> prices = new List <decimal>();

            foreach (var item in o)
            {
                od = order.GetOrderDetails(item.OrderID);
                ViewBag.OrderDtails = od;

                foreach (var detail in od)
                {
                    p = order.GetProduct(detail.ProductID);
                    if (p.UnitsInStock < detail.Quantity && p.UnitsInStock == 0)
                    {
                        ViewBag.IsBackOrder = true;
                    }
                    else
                    {
                        ViewBag.IsBackOrder = false;
                    }
                }
            }

            return(View(o));
        }
コード例 #2
0
 public ProductViewModel(ServiceReference.Product product)
 {
     Feature     = new List <FeatureViewModel>();
     Id          = product.Id;
     Name        = product.Name;
     Description = product.Description;
     Enabled     = product.Enabled;
     IsOffer     = product.IsOffer;
     Percent     = product.Percent;
     Price       = product.Price;
     StartDay    = product.StartDay;
     EndDay      = product.EndDay;
     Brand       = product.Brant;
     CategoryId  = product.CategoryId;
     Warranty    = product.Warranty;
 }
コード例 #3
0
        public decimal CalculateTotal()
        {
            int c = Convert.ToInt32(Session["CustomerId"]);

            ServiceReference.Service1Client order = new ServiceReference.Service1Client();
            var o   = order.GetOrder(c);
            var ord = new List <ServiceReference.OrderDetail>();
            var p   = new ServiceReference.Product();
            int i;

            decimal total = 1;

            if (Session["index"] != null)
            {
                i = Convert.ToInt32(Session["index"]);
            }
            else
            {
                i = 0;
            }

            if (i < o.Count)
            {
                foreach (var item in o)
                {
                    ord = order.GetOrderDetails(o[i].OrderID);

                    var od = ord[0];
                    p                = order.GetProduct(od.ProductID);
                    total            = od.Quantity * p.Price;
                    Session["index"] = +1;
                    return(total);
                }
            }
            return(total);
        }
コード例 #4
0
        public ActionResult Add(ProductViewModel product)
        {
            var app = new ServiceReference.ContractClient();

            var model = new ServiceReference.Product
            {
                Id          = 0,
                Name        = product.Name,
                Description = product.Description,
                Enabled     = true,
                IsOffer     = product.IsOffer,
                Percent     = product.Percent,
                Price       = product.Price,
                StartDay    = product.StartDay,
                EndDay      = product.EndDay,
                CategoryId  = product.CategoryId,
                Warranty    = product.Warranty,
                Brant       = product.Brant,
                TypeStock   = product.TypeStock,
                Stock       = product.Stock,
            };

            model.Feature = product.Feature.Where(x => x.Id >= 0 && x.Name != null).Select(x => new ServiceReference.Feature
            {
                Description = x.Description,
                Name        = x.Name,
                Id          = x.Id,
                ProductID   = model.Id
            }).ToList();
            model.Image = new List <ServiceReference.Image>();

            var id = app.AddProduct(model);


            for (int i = 0; i < Request.Files.Count; i++)
            {
                var file = Request.Files[i];
                if (file.FileName == string.Empty)
                {
                    continue;
                }
                var path = ImageHelper.SaveImage(id.ToString(), file, Server.MapPath("~/Image"));


                bool isMain = false;
                if (Request.Files.AllKeys[i] == "file")
                {
                    isMain = true;
                }
                var imagetosave = new ServiceReference.Image
                {
                    Url       = path,
                    IsMain    = isMain,
                    ProductId = id
                };
                model.Image.Add(imagetosave);
            }
            app.AddImageRange(model.Image);


            return(RedirectToAction("GetAll"));
        }