public JsonResult DeleteSeviceList(String Listid) { int itam = 0; try { String[] List = Listid.Split(','); Sevice sevice = new Sevice(); foreach (String id in List) { sevice = _context.Sevices.FirstOrDefault(x => x.Id == int.Parse(id) && x.IsDelete == false); sevice.IsDelete = true; _context.Update(sevice); itam++; } } catch (Exception er) { Message = "Successfully deleted " + itam + " sevice"; _context.SaveChangesAsync(); return(Json("Successfully deleted " + itam + " sevice")); } Message = "Successfully deleted " + itam + " sevice"; _context.SaveChangesAsync(); return(Json("Successfully deleted " + itam + " sevice")); }
public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Price,IsDelete")] Sevice sevice) { if (id != sevice.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(sevice); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!SeviceExists(sevice.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(sevice)); }
// GET: Admin/Sevices public async Task <IActionResult> Index(int?id) { Sevice sevice = null; if (id != null) { sevice = _context.Sevices.FirstOrDefault(x => x.Id == id); } return(View(sevice)); }
public async Task <IActionResult> Create([Bind("Id,Name,Price,IsDelete")] Sevice sevice) { if (ModelState.IsValid) { _context.Add(sevice); await _context.SaveChangesAsync(); Message = "Successfully create sevice"; return(RedirectToAction(nameof(Index))); } return(View(sevice)); }
public JsonResult DeleteSevice(int?id) { Sevice sevice = new Sevice(); sevice = _context.Sevices.FirstOrDefault(x => x.Id == id && x.IsDelete == false); if (sevice == null) { return(Json("Fail")); } sevice.IsDelete = true; _context.Update(sevice); _context.SaveChangesAsync(); Message = "Successfully deleted sevice"; return(Json("Success")); }