Пример #1
0
 public ActionResult EditProfile([Bind(Include = "Customer_Id,Customer_Name,Customer_Email,Customer_State,Customer_Phone,Customer_City,Customer_Password")] Customer_Details cd, HttpPostedFileBase image)
 {
     if (image != null)
     {
         cd.Customer_Profile = new byte[image.ContentLength];
         image.InputStream.Read(cd.Customer_Profile, 0, image.ContentLength);
     }
     else
     {
         int id  = (int)Session["id"];
         var img = Db.Customer_Details.Where(m => m.Customer_Id == id).Select(m => m.Customer_Profile).FirstOrDefault();
         if (img != null)
         {
             cd.Customer_Profile = img;
         }
     }
     if (ModelState.IsValid)
     {
         cd.Customer_Id     = (int)Session["id"];
         Db.Entry(cd).State = EntityState.Modified;
         Db.SaveChanges();
         return(RedirectToAction("Profile"));
     }
     return(View(cd));
 }
 public ActionResult EditProfile([Bind(Include = "Seller_ID,Seller_Name,Seller_Email,Seller_Phone,Seller_State,Seller_Password")] Seller_Details sd, HttpPostedFileBase image)
 {
     if (image != null)
     {
         sd.Seller_Photo = new byte[image.ContentLength];
         image.InputStream.Read(sd.Seller_Photo, 0, image.ContentLength);
     }
     else
     {
         int id  = (int)Session["sellerid"];
         var img = Db.Seller_Details.Where(m => m.Seller_ID == id).Select(m => m.Seller_Photo).FirstOrDefault();
         if (img != null)
         {
             sd.Seller_Photo = img;
         }
     }
     if (ModelState.IsValid)
     {
         sd.Seller_ID       = (int)Session["sellerid"];
         Db.Entry(sd).State = EntityState.Modified;
         Db.SaveChanges();
         return(RedirectToAction("Profile"));
     }
     return(View(sd));
 }