public async Task <IActionResult> Create([Bind("Id,Name,Description,Price,Image")] Good good)
        {
            //IFormFile imagemodel = good.Image;
            //HttpPostedFileBase postedFile;
            //string fileName = Path.GetFileNameWithoutExtension(imagemodel.FileName);

            //string filePath = "~/images/" + fileName;
            // good.Image.SaveAs(Server.MapPath(filePath));
            // string file = Path.Combine("~/images/", fileName);


            if (ModelState.IsValid)
            {
                /*
                 * string uniqueFileName = good.Image.FileName;
                 * Good good2 = new Good {
                 *  Id = good.Id,
                 *  Name = good.Name,
                 *  Description = good.Description,
                 *  Price = good.Price,
                 *  Image = uniqueFileName
                 * };*/

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

                return(RedirectToAction(nameof(Index)));
            }
            return(View(good));
        }
Beispiel #2
0
 public void Add(Good good)
 {
     _context.Add(good);
 }