// // GET: /UserTsk/Delete/5 public ActionResult Delete(int id) { UserTsk userTsk; using (IUnitOfWork unitOfWork = new TskDataDataContext(DbUtil.ConnectionString)) { IUserTskRep userTskRep = new UserTskRep(unitOfWork); userTsk = userTskRep.FindById(id); if (userTsk != null) { return(View(userTsk)); } else { return(RedirectToAction("Index", new { userId = Session["UserTsk_UserId"] })); } } }
public ActionResult Delete(int id, FormCollection collection) { UserTsk userTsk = null; try { using (IUnitOfWork unitOfWork = new TskDataDataContext(DbUtil.ConnectionString)) { IUserTskRep userTskRep = new UserTskRep(unitOfWork); userTsk = userTskRep.FindById(id); userTskRep.Delete(userTsk); unitOfWork.Submit(); } return(RedirectToAction("Index", new { userId = Session["UserTsk_UserId"] })); } catch { return(View(userTsk)); } }