Exemple #1
0
 public async Task<IActionResult> AddItem(Product products)
 {
     res resObj = new res();
     try
     {
         _context.Add(products);
         if(await _context.SaveChangesAsync() > 0)
         {
             resObj.resCode = 1;
             resObj.resMsg = "Item added successfully";
         }
         else
         {
             resObj.resCode = 0;
             resObj.resMsg = "Sorry,something went wrong.";
         }
     }
     catch (Exception ex)
     {
         string msg= ex.Message;
         resObj.resCode = 0;
         resObj.resMsg = "Sorry,something went wrong.";
     }
     return Json(resObj);   
 }
Exemple #2
0
        public async Task <IActionResult> Create([Bind("Id,Title,Release,Genre,Price,Rating")] Movies movies)
        {
            if (ModelState.IsValid)
            {
                _context.Add(movies);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(movies));
        }