public async Task <IActionResult> Create([Bind("Slider_id,Active,Title,Text")] Slider slider)
        {
            if (ModelState.IsValid)
            {
                _context.Add(slider);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(slider));
        }
        public async Task <IActionResult> Create([Bind("HeadingItem_id,Link,Name,HasChildren,Parent,Item_Column")] HeadingMenu headingMenu)
        {
            if (ModelState.IsValid)
            {
                _context.Add(headingMenu);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(headingMenu));
        }
예제 #3
0
        public async Task <IActionResult> Create([Bind("Type_id,Name")] Models.Type @type)
        {
            if (ModelState.IsValid)
            {
                _context.Add(@type);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(@type));
        }
        public async Task <IActionResult> Create([Bind("Subcategory_id,Name")] Subcategory subcategory)
        {
            if (ModelState.IsValid)
            {
                _context.Add(subcategory);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(subcategory));
        }
        public async Task <IActionResult> Create([Bind("Id,Name,NormalizedName,ConcurrencyStamp")] Role role)
        {
            if (ModelState.IsValid)
            {
                _context.Add(role);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(role));
        }
예제 #6
0
        public async Task <IActionResult> Create([Bind("Color_id,Name")] Color color)
        {
            if (ModelState.IsValid)
            {
                _context.Add(color);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(color));
        }
예제 #7
0
        public async Task <IActionResult> Create([Bind("FooterItem_id,Link,Name")] FooterMenu footerMenu)
        {
            if (ModelState.IsValid)
            {
                _context.Add(footerMenu);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(footerMenu));
        }
예제 #8
0
        public async Task <IActionResult> Create([Bind("Poll_id,Question,Active")] Poll poll)
        {
            if (ModelState.IsValid)
            {
                _context.Add(poll);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(poll));
        }
        public async Task <IActionResult> Create([Bind("Photo_id,Source,Alt,Product_id")] ProductPhoto productPhoto)
        {
            if (ModelState.IsValid)
            {
                _context.Add(productPhoto);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["Product_id"] = new SelectList(_context.Products, "Product_id", "Description", productPhoto.Product_id);
            return(View(productPhoto));
        }
        public async Task <IActionResult> Create([Bind("Photo_id,Source,Alt,Slider_id")] SliderPhoto sliderPhoto)
        {
            if (ModelState.IsValid)
            {
                _context.Add(sliderPhoto);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["Slider_id"] = new SelectList(_context.Sliders, "Slider_id", "Text", sliderPhoto.Slider_id);
            return(View(sliderPhoto));
        }
        public async Task <IActionResult> Create([Bind("Price_id,Net_price,Discount,Active,Product_id")] Price price)
        {
            if (ModelState.IsValid)
            {
                _context.Add(price);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["Product_id"] = new SelectList(_context.Products, "Product_id", "Description", price.Product_id);
            return(View(price));
        }
        public async Task <IActionResult> Create([Bind("Option_id,Name,Poll_id")] Option option)
        {
            if (ModelState.IsValid)
            {
                _context.Add(option);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["Poll_id"] = new SelectList(_context.Polls, "Poll_id", "Question", option.Poll_id);
            return(View(option));
        }
        public async Task <IActionResult> Create([Bind("Vote_id,UserId,Time,Option_id")] Vote vote)
        {
            if (ModelState.IsValid)
            {
                _context.Add(vote);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["Option_id"] = new SelectList(_context.Options, "Option_id", "Name", vote.Option_id);
            ViewData["UserId"]    = new SelectList(_context.Users, "Id", "Id", vote.UserId);
            return(View(vote));
        }
예제 #14
0
        public async Task <IActionResult> Create([Bind("Ordered_id,ProductVariant_Id,Order_Id,Amount")] Ordered ordered)
        {
            if (ModelState.IsValid)
            {
                _context.Add(ordered);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["Order_Id"]          = new SelectList(_context.Orders, "Order_id", "UserId", ordered.Order_Id);
            ViewData["ProductVariant_Id"] = new SelectList(_context.ProductVariants, "ProductVariant_Id", "ProductVariant_Id", ordered.ProductVariant_Id);
            return(View(ordered));
        }
예제 #15
0
        public async Task <IActionResult> Create([Bind("Rating_id,Product_id,UserId,Value")] Rating rating)
        {
            if (ModelState.IsValid)
            {
                _context.Add(rating);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["Product_id"] = new SelectList(_context.Products, "Product_id", "Description", rating.Product_id);
            ViewData["UserId"]     = new SelectList(_context.Users, "Id", "Id", rating.UserId);
            return(View(rating));
        }
예제 #16
0
        public async Task <IActionResult> Create([Bind("Order,CategoryId,BrandId,ImageUrl,Price,Manufacturer,Gender,Id,Name")] Product product)
        {
            if (ModelState.IsValid)
            {
                _context.Add(product);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["BrandId"]    = new SelectList(_context.Brands, "Id", "Id", product.BrandId);
            ViewData["CategoryId"] = new SelectList(_context.Categories, "Id", "Id", product.CategoryId);
            return(View(product));
        }
        public async Task <IActionResult> Create([Bind("Product_id,Name,Description,Category_id,Subcategory_id,Type_id")] Product product)
        {
            if (ModelState.IsValid)
            {
                _context.Add(product);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["Category_id"]    = new SelectList(_context.Categories, "Category_id", "Name", product.Category_id);
            ViewData["Subcategory_id"] = new SelectList(_context.Subcategories, "Subcategory_id", "Name", product.Subcategory_id);
            ViewData["Type_id"]        = new SelectList(_context.Types, "Type_id", "Name", product.Type_id);
            return(View(product));
        }
        public async Task <IActionResult> Create([Bind("ProductVariant_Id,Product_id,Size_id,Color_id,Quantity")] ProductVariant productVariant)
        {
            if (ModelState.IsValid)
            {
                _context.Add(productVariant);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["Color_id"]   = new SelectList(_context.Colors, "Color_id", "Name", productVariant.Color_id);
            ViewData["Product_id"] = new SelectList(_context.Products, "Product_id", "Description", productVariant.Product_id);
            ViewData["Size_id"]    = new SelectList(_context.Sizes, "Size_id", "Name", productVariant.Size_id);
            return(View(productVariant));
        }
예제 #19
0
        public HttpResponseMessage CreatePhone([FromBody] Phone phone)
        {
            try
            {
                _context.Add(phone);
                _context.SaveChanges();
            }
            catch (Exception ex)
            {
                return(new HttpResponseMessage(HttpStatusCode.NotFound));
            }

            return(new HttpResponseMessage(HttpStatusCode.OK));
        }
예제 #20
0
        public async Task <IActionResult> Create([Bind("Order,CategoryId,BrandId,ImageUrl,Price,Id,Name")] Product product)
        {
            if (ModelState.IsValid)
            {
                #region LoadImage
                var        path = ("wwwroot/images/product-details/" + product.ImageUrl);
                FileStream fs   = new FileStream(path, FileMode.Create);


                /*if (!file.Exists(path))
                 * {
                 *  // Create a file to write to.
                 *  using (StreamWriter sw = file.CreateText(path))
                 *  {
                 *      sw.WriteLine("Hello");
                 *      sw.WriteLine("And");
                 *      sw.WriteLine("Welcome");
                 *  }
                 * }*/
                var reclameContent = new byte[fs.Length];
                fs.Read(reclameContent, 0, Convert.ToInt32(fs.Length));


                var        myconnection = new SqlConnection();
                SqlCommand comm         = myconnection.CreateCommand();
                comm.CommandType = CommandType.StoredProcedure;

                /*SqlConnection sqlConnection = new SqlConnection($"../wwwroot/images/product - details/{product.ImageUrl}");
                 * comm.Connection = sqlConnection;*/
                comm.CommandText = $"~/wwwroot/images/product-details/{product.ImageUrl}";
                comm.Parameters.AddWithValue($"~/wwwroot/images/product-details/{product.ImageUrl}", reclameContent);
                fs.Close();
                //comm.ExecuteNonQuery();

                #endregion


                _context.Add(product);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["BrandId"]    = new SelectList(_context.Brands, "Id", "Id", product.BrandId);
            ViewData["CategoryId"] = new SelectList(_context.Categorys, "Id", "Id", product.CategoryId);
            return(View(product));
        }