Exemplo n.º 1
0
        public ActionResult DeleteConfirm(int id)
        {
            bool result = ProductRepo.Delete(id);

            UserViewModel modul = CompanyRepo.GetIdByName(User.Identity.Name);

            if (modul.Role == "Admin")
            {
                if (CompanyRepo.Delete(id))
                {
                    return(Json(new
                    {
                        success = result,
                        entity = "",
                        message = "delete success"
                    }, JsonRequestBehavior.AllowGet));
                }
                else
                {
                    return(Json(new
                    {
                        success = result,
                        entity = "",
                        message = "delete fail"
                    }, JsonRequestBehavior.AllowGet));
                }
            }
            else
            {
                return(new RedirectToRouteResult(new RouteValueDictionary(new { controller = "AccessDenied", action = "Index" })));
            }
        }
Exemplo n.º 2
0
 public ActionResult DeleteConfirm(int id)
 {
     if (CompanyRepo.Delete(id))
     {
         return(Json(new { success = true }, JsonRequestBehavior.AllowGet));
     }
     else
     {
         return(Json(new { success = false }, JsonRequestBehavior.AllowGet));
     }
 }
Exemplo n.º 3
0
 public void Delete(int id)
 {
     try
     {
         _repo.Delete(id);
     }
     catch (Exception ex)
     {
         _logger.Error(String.Format("Error during CompanyService.Delete({0}", id), ex);
         throw;
     }
 }
Exemplo n.º 4
0
        public ActionResult Delete(int id)
        {
            var data   = CompanyRepo.Find(id);
            var DelMsg = "客戶資料不存在。";

            if (data != null)
            {
                try
                {
                    CompanyRepo.Delete(data);
                    CompanyRepo.UnitOfWork.Commit();
                    DelMsg = "客戶資料刪除成功。";
                }
                catch (Exception ex)
                {
                    DelMsg = "客戶資料刪除失敗。錯誤訊息: " + ex.Message;
                }
            }
            TempData["DelMsg"] = DelMsg;
            return(RedirectToAction("Index"));
        }