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.")); } }
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)); } }
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.")); } }
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.")); } }
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.")); } }
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.")); } }