コード例 #1
0
        public ActionResult Create(Product_Details product_Details)
        {
            product_Details.ProductImages = "http://mvcshopuploadimages.gear.host/Uploads/default.png";
            product_Details.ProductStatus = 1;
            product_Details.ProductOrder  = 1;

            foreach (string file in Request.Files)
            {
                var postedFile = Request.Files[file];

                var res = UploadImgAsync(postedFile).ToString();
                //product_Details.ProductImages = res;
                var baseAddress = "http://mvcshopuploadimages.gear.host/Uploads/";
                var imgUrl      = Path.Combine(baseAddress, postedFile.FileName);

                product_Details.ProductImages = imgUrl;
            }
            if (ModelState.IsValid)
            {
                db.Product_Details.Add(product_Details);
                db.SaveChanges();
                return(RedirectToAction("Create"));
            }

            ViewBag.Brand_Id       = new SelectList(db.Brands, "Id", "BrandName", product_Details.Brand_Id);
            ViewBag.ProductType_Id = new SelectList(db.ProductTypes, "Id", "TypeName", product_Details.ProductType_Id);

            return(View(product_Details));
        }
コード例 #2
0
        public int Insert(User entity)
        {
            context.Users.Add(entity);
            context.SaveChanges();

            return(entity.Id);
        }
コード例 #3
0
        public ActionResult Create(string BrandName)
        {
            if (ModelState.IsValid)
            {
                var newBrand = new Brand
                {
                    BrandName = BrandName
                };
                db.Brands.Add(newBrand);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View("Index"));
        }
コード例 #4
0
        public ActionResult Create(string TypeName, int ParentTypeId, int TypeOrder)
        {
            if (ModelState.IsValid)
            {
                var productType = new ProductType()
                {
                    TypeName     = TypeName,
                    ParentTypeId = ParentTypeId,
                    TypeOrder    = TypeOrder
                };
                db.ProductTypes.Add(productType);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View("Index"));
        }