Пример #1
0
        public void SetUp()
        {
            var productRange = new ProductRange("1")
            {
                Id = 1
            };

            this.SalesProductRepository.GetSalesProducts()
            .Returns(new List <SalesProduct>
            {
                new SalesProduct("1")
                {
                    Id = 1, Description = "1 desc", ProductRange = productRange
                },
                new SalesProduct("2")
                {
                    Id = 2, Description = "2 desc", ProductRange = productRange
                },
                new SalesProduct("3")
                {
                    Id = 3, Description = "3 desc", PhasedOutOn = 1.October(2018), ProductRange = productRange
                },
                new SalesProduct("4")
                {
                    Id = 4, Description = "4 desc", ProductRange = new ProductRange("2")
                    {
                        Id = 2
                    }
                }
            });

            this.Results = this.Sut.GetSalesProductByRangeReport(1);
        }
Пример #2
0
        //Links the filename of the uploaded image to the record of the product in the database.
        public IProduct ProductImage(int id, ProductRange range, string filename)
        {
            var product = GetProduct(id, range);

            product.ProductPicture = filename;
            return(UpdateProduct(product));
        }
        public ActionResult DeleteConfirmed(int id)
        {
            ProductRange range = db.ProductRanges.Find(id);

            db.ProductRanges.Remove(range);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Пример #4
0
 public IActionResult OnGet(int id, ProductRange range)
 {
     this.Range = helper.GetEnumSelectList <ProductRange>();
     this.Item  = this.data.GetProduct(id, range);
     if (this.Item == null)
     {
         return(RedirectToPage("./NotFound"));
     }
     return(Page());
 }
 public ActionResult Edit([Bind(Include = "ID,ParcelID,ProductID,Code,IsSell,IsWarranty,Warranty,ProduceDate,Description,Quantity,CreatedDate,CreatedBy,UpdatedDate,UpdatedBy")] ProductRange productRange)
 {
     if (ModelState.IsValid)
     {
         db.Entry(productRange).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.ProductID = new SelectList(db.Products, "ID", "Name", productRange.ProductID);
     return(View(productRange));
 }
Пример #6
0
 public IActionResult OnPost(int id, ProductRange range)
 {
     if (dataAccess.Delete(id, range))
     {
         return(RedirectToPage("./ProductList"));
     }
     else
     {
         return(RedirectToPage("./NotFound"));
     }
 }
Пример #7
0
        private ProductRangeModel mapToModel(ProductRange entity)
        {
            var model = new ProductRangeModel {
                Id        = entity.Id,
                ProductId = entity.ProductId,
                RangeId   = entity.RangeId,
                RangeName = entity.Range.Name,
                IsMember  = true
            };

            return(model);
        }
Пример #8
0
 public IActionResult OnGet(int id, ProductRange range)
 {
     item = dataAccess.GetProduct(id, range);
     if (item == null)
     {
         return(RedirectToPage("./NotFound"));
     }
     else
     {
         return(Page());
     }
 }
        public ActionResult Edit([Bind(Include = "ID,GarmentTypeID,Name,SortOrder,Webpage,Available")] ProductRange range)
        {
            if (ModelState.IsValid)
            {
                db.Entry(range).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.GarmentTypes = new SelectList(db.GarmentTypes, "ID", "Name");
            return(View(range));
        }
Пример #10
0
 public IProduct GetProduct(int id, ProductRange range)
 {
     if (range == ProductRange.Topping)
     {
         var topping = db.Toppings.SingleOrDefault(i => i.Id == id);
         topping.Range = ProductRange.Topping;
         return(topping);
     }
     else
     {
         return(GetItem(id));
     }
 }
Пример #11
0
 public void SetUp()
 {
     this.productRange = new ProductRange {
         Id = 111
     };
     this.resource = new ProductRangeUpdateResource
     {
         RangeName        = "new name",
         RangeDescription = "new description",
         DateInvalid      = 1.December(2021).ToString("o")
     };
     this.ProductRangeRepository.FindById(111).Returns(this.productRange);
     this.result = this.Sut.Update(111, this.resource);
 }
Пример #12
0
        // GET: /Config/Ranges/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ProductRange range = db.ProductRanges.Find(id);

            if (range == null)
            {
                return(HttpNotFound());
            }
            return(View(range));
        }
Пример #13
0
        // GET: Administrator/ProductRanges/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ProductRange productRange = db.ProductRanges.Find(id);

            if (productRange == null)
            {
                return(HttpNotFound());
            }
            ViewBag.ProductID = new SelectList(db.Products, "ID", "Name", productRange.ProductID);
            return(View(productRange));
        }
Пример #14
0
        public void SetUp()
        {
            this.productRange =
                new ProductRange {
                Id = 2, RangeName = "name", RangeDescription = "desc", DateInvalid = null
            };
            this.ProductRangeService.GetById(2)
            .Returns(new SuccessResult <ProductRange>(this.productRange));

            this.Response = this.Browser.Get(
                "/products/maint/product-ranges/2",
                with =>
            {
                with.Header("Accept", "application/json");
            }).Result;
        }
Пример #15
0
        // GET: /Config/Ranges/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ProductRange range = db.ProductRanges.Find(id);

            if (range == null)
            {
                return(HttpNotFound());
            }

            ViewBag.GarmentTypes = new SelectList(db.GarmentTypes, "ID", "Name");
            return(View(range));
        }
Пример #16
0
        private void GetProductRange()
        {
            DbManager    db       = DbManager.GetInstance();
            ProductRange range    = db.GetProductRangeForLocation(ShopGlobals.Location);
            var          products = db.GetAllProductsWithIngredients();

            foreach (var item in range.Products)
            {
                if (item.Category.Equals(ProductCategory.beverage_coffee) || item.Category.Equals(ProductCategory.beverage_noncoffee))
                {
                    var ingredients = products.Where(p => p.Id == item.Id).Select(p => p.Ingredients).Single();
                    item.Ingredients = ingredients;
                }
            }

            ShopGlobals.LocalProductRange = range;
        }
Пример #17
0
 public bool Delete(int id, ProductRange range)
 {
     if (range != ProductRange.Topping)
     {
         return(this.DeleteItem(id));
     }
     else
     {
         var toDelete = db.Toppings.SingleOrDefault(i => i.Id == id);
         db.Toppings.Remove(toDelete);
         if (db.SaveChanges() > 0)
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
 }
        public void SetUp()
        {
            this.productRange = new ProductRange {
                Id = 3, RangeName = "name"
            };
            this.resource = new ProductRangeUpdateResource
            {
                RangeName = "name"
            };
            this.ProductRangeService.Update(3, Arg.Any <ProductRangeUpdateResource>())
            .Returns(new SuccessResult <ProductRange>(this.productRange));

            this.Response = this.Browser.Put(
                "/products/maint/product-ranges/3",
                with =>
            {
                with.Header("Accept", "application/json");
                with.Header("Content-Type", "application/json");
                with.JsonBody(this.resource);
            }).Result;
        }
Пример #19
0
        // GET: /Config/Ranges/ColorsSizes/5
        public ActionResult ColorsSizes(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ProductRange range = db.ProductRanges.Find(id);

            if (range == null)
            {
                return(HttpNotFound());
            }

            ViewBag.Colors = db.ProductColors.Where(x => x.ProductRangeID == range.ID);

            var allSizes = db.ProductSizes.Where(x => x.ProductColor.ProductRangeID == range.ID).OrderBy(x => x.SortOrder).ThenBy(x => x.Name).Select(x => x.Name);

            ViewBag.Sizes = GetDistinctPreserveOrder(allSizes);

            return(View(range));
        }
Пример #20
0
        public void SetUp()
        {
            this.productRange = new ProductRange {
                Id = 3, RangeName = "name", RangeDescription = "desc"
            };
            this.resource = new ProductRangeResource
            {
                RangeName        = "name",
                RangeDescription = "desc"
            };
            this.ProductRangeService.Add(Arg.Any <ProductRangeResource>())
            .Returns(new CreatedResult <ProductRange>(this.productRange));

            this.Response = this.Browser.Post(
                "/products/maint/product-ranges",
                with =>
            {
                with.Header("Accept", "application/json");
                with.Header("Content-Type", "application/json");
                with.JsonBody(this.resource);
            }).Result;
        }
Пример #21
0
        public Error UpdateProduct(ProductModel model)
        {
            Error error = new Error();

            foreach (var pr in model.ProductRanges)
            {
                ProductRange tempPr = null;
                if (pr.Id != 0)
                {
                    tempPr = db.FindProductRange(pr.Id); // Check to see if record is in db
                }
                if (tempPr == null)                      // NOT in db
                {
                    if (pr.IsMember)
                    {
                        tempPr           = new ProductRange();
                        tempPr.ProductId = pr.ProductId;
                        tempPr.RangeId   = pr.RangeId;

                        db.InsertOrUpdateProductRange(tempPr);
                    }
                }
                else     // IN db
                {
                    if (!pr.IsMember)
                    {
                        db.DeleteProductRange(tempPr.Id);
                    }
                }
            }

            Product temp = db.FindProduct(model.Id);

            temp.Mpl = model.Mpl;

            db.InsertOrUpdateProduct(temp, false);

            return(error);
        }
Пример #22
0
 public List <Item> GetRange(ProductRange range)
 {
     return(SaleItems.Where(i => i.Range == range).ToList());
 }
Пример #23
0
 public void SetUpContext()
 {
     this.Sut = new ProductRange {
         Id = 1
     };
 }
        public async Task <ActionResult> PostImage(IFormFile image, [FromQuery] int id, [FromQuery] ProductRange range)
        {
            if (image != null)
            {
                string folder   = Path.Combine(webHost.WebRootPath, "images");
                string fileName = Guid.NewGuid().ToString() + "_" + image.FileName;
                string filePath = Path.Combine(folder, fileName);
                using (var fileStream = new FileStream(filePath, FileMode.Create))
                {
                    image.CopyTo(fileStream);
                }
                var product = dataAccess.ProductImage(id, range, fileName);
                return(CreatedAtAction("PostImage", fileName));
            }


            return(NoContent());
        }