예제 #1
0
 public HttpResponseMessage DeleteInstAnnouncement(int AnnouncementId)
 {
     try
     {
         var user = UserHelper.GetCurrentUser();
         repository.DeleteAnnouncement(AnnouncementId, a => a.Type == "I" && a.InstituteId == user.InstId);
         return(ResponseWrapper.SuccessResponse("删除成功"));
     }
     catch (Exception e)
     {
         return(ResponseWrapper.ExceptionResponse(e));
     }
 }
 public ActionResult Delete(Guid id, FormCollection collection)
 {
     try
     {
         // TODO: Add delete logic here
         announcementRepository.DeleteAnnouncement(id);
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View("Delete"));
     }
 }
        public IHttpActionResult DeleteAnnouncement(int id)
        {
            if (!user_service.IsAuthorizedToDeleteAnnouncements())
            {
                return(Unauthorized());
            }

            try{
                announcement_repository.DeleteAnnouncement(id);
                return(Ok());
            }
            catch (ObjectNotFoundException e) {
                return(NotFound());
            }
        }
예제 #4
0
        public ActionResult Delete(string id = "")
        {
            try
            {
                int _id;
                AnnouncementInfo _announcement = null;

                if (!int.TryParse(id, out _id))
                {
                    return(RedirectToAction("Manage", "Announcement"));
                }

                using (AnnouncementRepository Repo = new AnnouncementRepository())
                {
                    _announcement = Repo.GetAnnouncementById(_id);
                }

                if (_announcement == null)
                {
                    return(RedirectToAction("Manage", "Announcement"));
                }

                using (AnnouncementRepository Repo = new AnnouncementRepository())
                {
                    Repo.DeleteAnnouncement(_id);
                }

                TempData["Msg"] = AlertMessageProvider.SuccessMessage("Announcement deleted successfully.");

                return(RedirectToAction("Manage", "Announcement"));
            }

            catch (Exception ex)
            {
                return(View("Error", new HandleErrorInfo(ex, "Announcement", "Delete")));
            }
        }