public ActionResult EditPhone(AddPhone data) { if (ModelState.IsValid) { var PassedData = db.Phones.Find(data.ID); PassedData.ProductID = data.ID; PassedData.model = data.model; PassedData.Details = data.Details; PassedData.Brand = data.Brand; PassedData.Price = data.Price; PassedData.sale = data.sale; PassedData.PicesNo = data.PicesNO; MemoryStream target = new MemoryStream(); data.file.InputStream.CopyTo(target); PassedData.img = target.ToArray(); db.Entry(PassedData).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("DashBoard")); } Admon.name = Adminloggedin.name; Admon.password = Adminloggedin.password; Admon.Type = Adminloggedin.type; ViewBag.Message = Admon; return(View(data)); }
public ActionResult AddPhone(AddPhone addphone) { if (ModelState.IsValid) { Phone phoneData = new Phone(); phoneData.img = new byte[addphone.file.ContentLength]; MemoryStream target = new MemoryStream(); addphone.file.InputStream.CopyTo(target); phoneData.img = target.ToArray(); phoneData.model = addphone.model; phoneData.Details = addphone.Details; phoneData.Brand = addphone.Brand; phoneData.Price = addphone.Price; phoneData.sale = addphone.sale; phoneData.PicesNo = addphone.PicesNO; db.Phones.Add(phoneData); db.SaveChanges(); return(RedirectToAction("DashBoard")); } Admon.name = Adminloggedin.name; Admon.password = Adminloggedin.password; Admon.Type = Adminloggedin.type; ViewBag.Message = Admon; return(View(addphone)); }
public ActionResult EditPhone(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Phone data = db.Phones.Find(id); if (data == null) { return(HttpNotFound()); } AddPhone PassedData = new AddPhone(); PassedData.ID = data.ProductID; PassedData.model = data.model; PassedData.Details = data.Details; PassedData.Brand = data.Brand; PassedData.Price = data.Price; PassedData.sale = data.sale; PassedData.PicesNO = data.PicesNo; PassedData.img = data.img; Admon.name = Adminloggedin.name; Admon.password = Adminloggedin.password; Admon.Type = Adminloggedin.type; ViewBag.Message = Admon; return(View(PassedData)); }
private void chooserPhone_Click(object sender, RoutedEventArgs e) { AddPhone addWnd = new AddPhone(); addWnd.ShowDialog(); }