Пример #1
0
 public ActionResult update_customer(Add_Store obj, HttpPostedFileBase getimg)
 {
     if (obj.description != null)
     {
         if (getimg != null)
         {
             //----------------------new_folder------------------------
             string checkid     = Session["user_user"].ToString();
             string name_folder = Path.Combine(Server.MapPath("~/img/user_img"), checkid);
             //----------------------name and save img------------------------
             string fileName  = Path.GetFileNameWithoutExtension(getimg.FileName);
             string extention = Path.GetExtension(getimg.FileName);
             fileName = fileName + DateTime.Now.ToString("yyyyMMdd") + extention;
             string path = Path.Combine(Server.MapPath("~/img/user_img" + "/" + checkid), fileName);
             if (System.IO.Directory.Exists(name_folder))
             {
                 using (Order_Food_dbEntities1 db = new Order_Food_dbEntities1())
                 {
                     //List<string> get_list = get_check.ToList();
                     //List<string> get_name = getname.ToList();
                     //get_cat.category = get_list.ToString();
                     //get_cat.customer_name = get_name.ToString();
                     //db.Get_catagory.Add(get_cat);
                     getimg.SaveAs(path);
                     obj.pic  = fileName;
                     obj.name = checkid;
                     db.Add_Store.Add(obj);
                     db.SaveChanges();
                 }
             }
             else
             {
                 using (Order_Food_dbEntities1 db = new Order_Food_dbEntities1())
                 {
                     Directory.CreateDirectory(name_folder);
                     getimg.SaveAs(path);
                     obj.pic  = fileName;
                     obj.name = checkid;
                     db.Add_Store.Add(obj);
                     db.SaveChanges();
                 }
             }
             //List<string> myList = new List<string>();
             //Session["var"] = myList;
         }
     }
     else
     {
         using (Order_Food_dbEntities1 db = new Order_Food_dbEntities1())
         {
             string checkid = Session["user_user"].ToString();
             var    img     = db.Add_Store.Where(s => s.name == checkid).Select(s => s.pic).ToList();
             return(View(img));
         }
     }
     //string fileName = Path.GetFileName(Food_Picture_pic.FileName);
     //string path = Path.Combine(Server.MapPath("~/img/user_img"), fileName);
     //Food_Picture_pic.SaveAs(path);
     return(RedirectToAction("Homeaddstore", "UsingU"));
 }
Пример #2
0
        public Add_Store model_car()
        {
            Add_Store modeluser = new Add_Store();

            using (Order_Food_dbEntities1 db = new Order_Food_dbEntities1())
            {
                modeluser.category2 = db.Category.ToList <Category>();
            }
            return(modeluser);
        }