Exemplo n.º 1
0
 public AppReturn PermanentDelete(int id)
 {
     try
     {
         Mail mail = _context.Mails.Find(id);
         mail.IsPermanentDelete = true;
         return(AppReturn.Successful("Successfully deleted mail permanently"));
     }
     catch (Exception)
     {
         // TODO : Logger has to add here.
         return(AppReturn.InvalidOperation("An error has occured when deleting email."));
     }
 }
Exemplo n.º 2
0
        public AppReturn Add(TEntity entity)
        {
            try
            {
                DbSet.Add(entity);

                Log.Info("Successfully added model.");
                return(AppReturn.Successful());
            }
            catch (Exception e)
            {
                Log.Error("An unexpected error has occured while adding model.", e);
                return(AppReturn.InvalidOperation(e.Message));
            }
        }
Exemplo n.º 3
0
        public AppReturn Update(TEntity entity)
        {
            try
            {
                DbSet.Attach(entity);
                _context.Entry(entity).State = EntityState.Modified;

                Log.Info($"{ entity.GetType() } updated successfuly.");
                return(AppReturn.Successful());
            }
            catch (Exception e)
            {
                Log.Error($"An unexpected error has occured while updating { entity.GetType() }.", e);
                return(AppReturn.InvalidOperation(e.Message));
            }
        }
        public AppReturn Delete(int id)
        {
            try
            {
                Announcement announcement = _context.Announcements.Find(id);
                announcement.IsActive = false;

                Log.Info("Successfully deleted announcement.");
                return(AppReturn.Successful("Announcement deleted successfully."));
            }
            catch (Exception e)
            {
                Log.Error("An unexpected error has occured while deleting announcement.", e);
                return(AppReturn.InvalidOperation("An error has occured when deleting announcement."));
            }
        }
Exemplo n.º 5
0
        public AppReturn Delete(int id)
        {
            try
            {
                User user = _context.Users.Find(id);
                user.IsActive = false;

                Log.Info("Successfully deleted user.");
                return(AppReturn.Successful("User deleted successfully."));
            }
            catch (Exception e)
            {
                Log.Error("An unexpected error has occured while deleting user.", e);
                return(AppReturn.InvalidOperation("An error has occured when deleting user."));
            }
        }
Exemplo n.º 6
0
        public AppReturn Delete(int id)
        {
            try
            {
                Note note = _context.Notes.Find(id);
                note.IsActive = false;
                Log.Info("Successfully deleted note.");

                return(AppReturn.Successful("Note deleted successfully."));
            }
            catch (Exception e)
            {
                Log.Error("An unexpected error has occured while deleting note.", e);
                return(AppReturn.InvalidOperation("An error has occured when deleting note."));
            }
        }
Exemplo n.º 7
0
        public AppReturn Delete(int id)
        {
            try
            {
                Mail mail = _context.Mails.Find(id);
                mail.IsActive   = false;
                mail.DeleteDate = DateTime.Now;

                Log.Info("Successfully deleted email.");
                return(AppReturn.Successful("Mail deleted successfully."));
            }
            catch (Exception e)
            {
                Log.Error("An unexpected error has occured while deleting email.", e);
                return(AppReturn.InvalidOperation("An error has occured when deleting email."));
            }
        }