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); }
//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")); }
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)); }
public IActionResult OnPost(int id, ProductRange range) { if (dataAccess.Delete(id, range)) { return(RedirectToPage("./ProductList")); } else { return(RedirectToPage("./NotFound")); } }
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); }
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)); }
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)); } }
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); }
// 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)); }
// 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)); }
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; }
// 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)); }
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; }
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; }
// 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)); }
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; }
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); }
public List <Item> GetRange(ProductRange range) { return(SaleItems.Where(i => i.Range == range).ToList()); }
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()); }