Exemplo n.º 1
0
 public bool DeleteEvent(string loginedUserId, int eventId)
 {
     var(dataUser, dataBigEvent) = serviceHelper.IsUserHasAccessToEvent(loginedUserId, eventId);
     if (dataBigEvent != null)
     {
         var success = serviceHelper.WrapMethod(() => eventRepos.Delete(dataBigEvent.EventId));
         if (success)
         {
             success = serviceHelper.WrapMethod(() => notificationRepos.DeleteNotification(dataBigEvent.EventId));
         }
         return(success);
     }
     return(false);
 }
        public IHttpActionResult DeleteNotification(DeleteNotificationRequest deleteNotificationRequest)
        {
            var responses = new Responses();

            try
            {
                if (!ModelState.IsValid)
                {
                    return(BadRequest(ModelState));
                }

                if (Utility.UserId < 0)
                {
                    return(BadRequest(Utility.INVALID_USER));
                }

                var notification = new Notification()
                {
                    NotificationId = deleteNotificationRequest.NotificationId,
                    ModifiedBy     = Utility.UserId
                };

                int result = iNotification.DeleteNotification(notification);
                switch (result)
                {
                case 1:
                    responses.Status      = Utility.SUCCESS_STATUS_RESPONSE;
                    responses.Description = "Notification deleted successfully.";
                    break;

                case -2:
                    responses.Status      = Utility.ERROR_STATUS_RESPONSE;
                    responses.Description = "Notification doesn't exist.";
                    break;

                default:
                    responses.Status      = Utility.ERROR_STATUS_RESPONSE;
                    responses.Description = "Error while deleting notification.";
                    break;
                }
            }
            catch (Exception ex)
            {
                responses.Status      = Utility.ERROR_STATUS_RESPONSE;
                responses.Description = "Error while deleting notification.";

                Utility.WriteLog("DeleteNotification", deleteNotificationRequest, "Error while deleting notification. (NotificationAdminController)", ex.ToString());
            }
            return(Ok(responses));
        }