public ActionResult Rsellproduct(int id, FormCollection fc)
        {
            try
            {
                //string iframe = fc["iframe"];
                // var cus2 = (customer)Session["UserID"];
                customer cus = Re.customers.Where(a => a.Customer_Id == id).Single();;

                if (ModelState.IsValid)
                {
                    var file = Request.Files[0];
                    if (file != null & file.ContentLength > 0)
                    {
                        var fileName = Path.GetFileName(file.FileName);
                        var path     = Path.Combine(Server.MapPath("~/Content/images/images_Shop"), fileName);
                        file.SaveAs(path);
                        cus.Images = fileName;
                    }
                }
                cus.Shop_name       = fc["Shop_name"];
                cus.Name_Bank       = fc["Name_Bank"];
                cus.Name_Owner      = fc["Name_Owner"];
                cus.Card_No         = fc["Card_No"];
                cus.Id_Bank         = fc["Id_Bank"];
                cus.UserType        = "Shop";
                Re.Entry(cus).State = EntityState.Modified;
                //Re.customers.Add(cus);
                Re.SaveChanges();
            }
            catch (System.Data.Entity.Validation.DbEntityValidationException dbEx)
            {
                Exception raise = dbEx;
                foreach (var validationErrors in dbEx.EntityValidationErrors)
                {
                    foreach (var validationError in validationErrors.ValidationErrors)
                    {
                        string message = string.Format("{0}:{1}",
                                                       validationErrors.Entry.Entity.ToString(),
                                                       validationError.ErrorMessage);
                        // raise a new exception nesting
                        // the current instance as InnerException
                        raise = new InvalidOperationException(message, raise);
                    }
                }
                throw raise;
            }
            Session["Shop_name"] = "0";
            Session["UserName"]  = null;
            Session["UserType"]  = null;
            return(RedirectToAction("Conditiontwo", "Account", new { area = "" }));
            //return View("Conditiontwo");
        }
 public ActionResult Edit([Bind(Include = "Sum_Id,Product_Id,Product_Id2,Product_Id3")] SumCargo sumCargo)
 {
     if (ModelState.IsValid)
     {
         db.Entry(sumCargo).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.Product_Id  = new SelectList(db.Pets, "Pet_Id", "Name", sumCargo.Product_Id);
     ViewBag.Product_Id2 = new SelectList(db.Products, "Product_Id", "Name", sumCargo.Product_Id2);
     ViewBag.Product_Id3 = new SelectList(db.Trainers, "Trainer_Id", "Name", sumCargo.Product_Id3);
     return(View(sumCargo));
 }
示例#3
0
        public ActionResult Updatepic(int id, FormCollection fc)
        {
            Trainer T   = new Trainer();
            Product pro = new Product();
            Pet     pet = new Pet();

            if (id != null)
            {
                if (id <= 1 || id >= 39999)
                {
                    if (ModelState.IsValid)
                    {
                        var file = Request.Files[0];
                        if (file != null && file.ContentLength > 0)
                        {
                            var fileName = Path.GetFileName(file.FileName);
                            var path     = Path.Combine(Server.MapPath("~/Content/images/images_pet"), fileName);
                            file.SaveAs(path);
                            pet.Images2 = fileName;
                        }
                    }

                    if (ModelState.IsValid)
                    {
                        var file = Request.Files[0];
                        if (file != null && file.ContentLength > 0)
                        {
                            var fileName = Path.GetFileName(file.FileName);
                            var path     = Path.Combine(Server.MapPath("~/Content/images/images_pet"), fileName);
                            file.SaveAs(path);
                            pet.Images3 = fileName;
                        }
                    }


                    if (ModelState.IsValid)
                    {
                        var file = Request.Files[0];
                        if (file != null && file.ContentLength > 0)
                        {
                            var fileName = Path.GetFileName(file.FileName);
                            var path     = Path.Combine(Server.MapPath("~/Content/images/images_pet"), fileName);
                            file.SaveAs(path);
                            pet.Images4 = fileName;
                        }
                    }

                    if (ModelState.IsValid)
                    {
                        var file = Request.Files[0];
                        if (file != null && file.ContentLength > 0)
                        {
                            var fileName = Path.GetFileName(file.FileName);
                            var path     = Path.Combine(Server.MapPath("~/Content/images/images_pet"), fileName);
                            file.SaveAs(path);
                            pet.Images5 = fileName;
                        }
                    }
                    Cp.Entry(pet).State = EntityState.Modified;
                    //Cp.Pets.Add(pet);
                    Cp.SaveChanges();
                }
            }
            return(View());
        }