public async Task <IActionResult> Create(Photo_Menu photo) { if (ModelState["Title"].ValidationState == ModelValidationState.Invalid || ModelState["Photo"].ValidationState == ModelValidationState.Invalid) { return(View()); } if (!photo.Photo.IsImage()) { ModelState.AddModelError("Photo", "Shekil novunu duz secin"); return(View()); } if (!photo.Photo.CheckImageSize(2)) { ModelState.AddModelError("Photo", "Shekil hecmi coxdur"); return(View()); } string filename = await photo.Photo.CopyImage(_env.WebRootPath, "slider"); photo.Image = filename; await _context.Photo_Menus.AddAsync(photo); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); }
public async Task <IActionResult> DeletePost(int?id) { Reserv_Table reserv = await _context.Reserv_Tables.FindAsync(id); _context.Reserv_Tables.Remove(reserv); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); }
public async Task <IActionResult> Create(Menu_Content menu) { if (!ModelState.IsValid) { return(View()); } await _context.Menu_Contents.AddAsync(menu); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); }
public async Task <IActionResult> Create(Location location) { if (!ModelState.IsValid) { return(View()); } await _context.Locations.AddAsync(location); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); }
public async Task <IActionResult> Create(UniqueHistory unique) { if (!ModelState.IsValid) { return(View()); } await _context.UniqueHistories.AddAsync(unique); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); }
public async Task <IActionResult> BuscketProduct(int?id, string count) { var UserId = getuser(); List <ShopNowProduct> myproducts = new List <ShopNowProduct>(); var busket = _context.Busckets.Where(bus => bus.AppUserId == UserId); if (id != null) { ShopNowProduct shopNowProduct = await _context.ShopNowProducts.FindAsync(id); if (!string.IsNullOrWhiteSpace(count)) { int cnt = int.Parse(count); for (int i = 0; i < cnt; i++) { Buscket bs = new Buscket(); bs.ShopNowProductId = shopNowProduct.Id; bs.AppUserId = UserId; _context.Busckets.Add(bs); } } await _context.SaveChangesAsync(); foreach (var i in busket) { var products = _context.ShopNowProducts.Find(i.ShopNowProductId); myproducts.Add(products); } homeModel.ShopNowProducts = myproducts; return(View(homeModel)); } return(NotFound()); }