public ActionResult Create([Bind(Include = "ID,BusinessId")] string Name, string Description, string Item_Type, double Discount, double Price, double Tax, HttpPostedFileBase pic, int BusinessID) { // string myId = User.Identity.GetUserId(); // PersonalAccount p_acc = db.personalaccounts.ToList().Where(x => x.AppUserId == myId).FirstOrDefault(); ProfilePic_Product profilePic = new ProfilePic_Product(); profilePic.BusinessId = BusinessID; profilePic.Name = Name; profilePic.Description = Description; profilePic.Item_Type = Item_Type; profilePic.Discount = Discount; profilePic.Price = Price; profilePic.Tax = Tax; if (ModelState.IsValid) { if (pic != null && pic.ContentLength > 0) { var avatar = new File_Product { FileName = System.IO.Path.GetFileName(pic.FileName), FileType_Product = FileType_Product.Avatar, ContentType = pic.ContentType, BusinessId = BusinessID }; using (var reader = new System.IO.BinaryReader(pic.InputStream)) { avatar.Content = reader.ReadBytes(pic.ContentLength); } profilePic.Files_Product = new List <File_Product> { avatar }; } db.profilepic_products.Add(profilePic); db.SaveChanges(); int propicid = profilePic.ID; return(RedirectToAction("ProductUploaded", "Pages", new { prod_id = propicid, business_id = BusinessID })); } return(View(profilePic)); }
public ActionResult MakeDealPage(int prod_id) { string myid = User.Identity.GetUserId(); ActiveProfile act = db.activeprofiles.ToList() .Where(x => x.ApplicationUserId == myid).FirstOrDefault(); if (act.AccountType == "Business") { ProfilePic_Product prod = db.profilepic_products.ToList() .Where(x => x.ID == prod_id && x.BusinessId == act.ActiveProfileID).FirstOrDefault(); return(View(prod)); } else { return(RedirectToAction("Index", "Home")); } }
public ActionResult ProductDetails(int id) { ProfilePic_Product p = db.profilepic_products.ToList().Where(x => x.ID == id).FirstOrDefault(); return(View(p)); }