public ISPProductViewModel() { ISP = new ISP(); ISPs = new List <ISP>(); ISPProduct = new ISPProduct(); ISPProducts = new List <ISPProduct>(); }
public ProductViewModel() { Product = new ISPProduct(); Products = new List <ISPProduct>(); ISPs = new List <ISP>(); User = new User(); Orders = new List <Order>(); Specials = new List <Special>(); }
public ActionResult Edit(ISPProduct model, HttpPostedFileBase upload) { if (Request.Cookies["ISPAdmin"] == null) { return(RedirectToAction("Login", "Account")); } if (ModelState.IsValid) { svc.EditProduct(model, upload); } return(RedirectToAction("Index")); }
public bool SaveProduct(ISPProduct product, HttpPostedFileBase upload) { if (upload != null && upload.ContentLength > 0) { var image = new Asset { AssetPath = Guid.NewGuid() + Path.GetFileName(upload.FileName), }; string targetFolder = HttpContext.Current.Server.MapPath("~/Assets/ISPProductLogo/"); string targetPath = Path.Combine(targetFolder, image.AssetPath); upload.SaveAs(targetPath); product.ISPLogo = image; } product.IsActive = false; db.ISPProducts.Add(product); db.SaveChanges(); return(false); }
public bool EditProduct(ISPProduct product, HttpPostedFileBase upload) { var prodToUpdate = db.ISPProducts.Include(p => p.ISPLogo).SingleOrDefault(p => p.ISPProductId == product.ISPProductId); if (upload != null && upload.ContentLength > 0) { if (prodToUpdate != null) { if (prodToUpdate.ISPLogo != null) { //delete the file from Assets folder string path = HttpContext.Current.Server.MapPath("~/Assets/ISPProductLogo/" + prodToUpdate.ISPLogo.AssetPath); if (File.Exists(path)) { File.Delete(path); } //delete the file path object from the DB db.Assets.Remove(prodToUpdate.ISPLogo); db.SaveChanges(); } var image = new Asset { AssetPath = Guid.NewGuid() + Path.GetFileName(upload.FileName), }; string targetFolder = HttpContext.Current.Server.MapPath("~/Assets/ISPProductLogo/"); string targetPath = Path.Combine(targetFolder, image.AssetPath); upload.SaveAs(targetPath); prodToUpdate.ISPLogo = image; } } prodToUpdate.LineSpeed = product.LineSpeed; prodToUpdate.Description = product.Description; prodToUpdate.ProductName = product.ProductName; prodToUpdate.IsCapped = product.IsCapped; prodToUpdate.Cap = product.Cap; prodToUpdate.UpSpeed = product.UpSpeed; prodToUpdate.IsSpecial = product.IsSpecial; prodToUpdate.OnceOfFFPaymentForM2M = product.OnceOfFFPaymentForM2M; prodToUpdate.IsM2MClient = product.IsM2MClient; prodToUpdate.M2MMonthlyCost = product.M2MMonthlyCost; prodToUpdate.Is24MClient = product.Is24MClient; prodToUpdate.MonthlyCost = product.MonthlyCost; prodToUpdate.SetupCost = product.SetupCost; prodToUpdate.M2MSetupCost = product.M2MSetupCost; prodToUpdate.IsM2MFrogfootLink = product.IsM2MFrogfootLink; prodToUpdate.Attr1 = product.Attr1; prodToUpdate.Attr2 = product.Attr2; prodToUpdate.Attr3 = product.Attr3; prodToUpdate.Attr4 = product.Attr4; prodToUpdate.Info1Heading = product.Info1Heading; prodToUpdate.Info2Heading = product.Info2Heading; prodToUpdate.Info3Heading = product.Info3Heading; prodToUpdate.Info4Heading = product.Info4Heading; prodToUpdate.Info1 = product.Info1; prodToUpdate.Info2 = product.Info2; prodToUpdate.Info3 = product.Info3; prodToUpdate.Info4 = product.Info4; prodToUpdate.Shaped = product.Shaped; prodToUpdate.Router = product.Router; prodToUpdate.Phone = product.Phone; prodToUpdate.Install = product.Install; prodToUpdate.Video = product.Video; prodToUpdate.MobileData = product.MobileData; prodToUpdate.CCTV = product.CCTV; db.SaveChanges(); return(true); }
public void EditProduct(ISPProduct model, HttpPostedFileBase upload) { ispRepo.EditProduct(model, upload); }
//private Random rnd = new Random(); public PackageViewModel() { Product = new ISPProduct(); Products = new List <ISPProduct>(); }