public async Task <Note> GetByAccessLink(string accessLink) { using (var ctx = new MyNoteContext()) { return(await ctx.Notes.Where(n => n.ShareLink == accessLink).FirstAsync()); } }
private async Task AuditNoteActions(Note note, AuditAction action) { using (var ctx = new MyNoteContext()) { var auditNote = new AuditEnrty() { Action = Enum.GetName(typeof(AuditAction), action), NoteId = note.Id, Actor = note.Owner, Time = DateTime.Now }; switch (action) { case AuditAction.CreateNote: case AuditAction.UpdateNote: auditNote.Details = $"Title:{note.Title}, Content:{note.Content}"; break; case AuditAction.ShareNote: auditNote.Details = $"ShareLink:{note.ShareLink}"; break; } ctx.AuditEntries.Add(auditNote); await ctx.SaveChangesAsync(); } }
public async Task <Note> Get(int id) { using (var ctx = new MyNoteContext()) { return(await ctx.Notes.FindAsync(id)); } }
public async Task <IEnumerable <NoteDigest> > GetAllNoteDigestByUser(string userName) { using (var ctx = new MyNoteContext()) { var notes = await ctx.Notes.Where(n => n.Owner == userName).OrderByDescending(n => n.Created).ToListAsync(); return(notes); } }
public async Task Delete(int id) { using (var ctx = new MyNoteContext()) { var note = ctx.Notes.Find(id); ctx.Notes.Remove(note); //var note = ctx.Notes.First(n => n.Id == id); //ctx.Remove(note); await ctx.SaveChangesAsync(); } }
public async Task Insert(Note note) { using (var ctx = new MyNoteContext()) { note.Created = note.Modified = DateTime.Now; //TODO: return Id //ctx.Notes.Add(note); var zzz = ((DbSet <Note>)ctx.Set <Note>()) .Add(note); await ctx.SaveChangesAsync(); } }
public async Task RegisterUser(UserModel user, IdentityResult identityResult) { using (var ctx = new MyNoteContext()) { var auditNote = new AuditEnrty() { Action = Enum.GetName(typeof(AuditAction), AuditAction.RegisterUser), Actor = user.UserName, Time = DateTime.Now, Details = identityResult.Succeeded ? "Success." : string.Join("; ", identityResult.Errors) }; ctx.AuditEntries.Add(auditNote); await ctx.SaveChangesAsync(); } }
public async Task Update(Note note) { using (var ctx = new MyNoteContext()) { var dbNote = ctx.Notes.First(u => u.Id == note.Id); note.Created = dbNote.Created; note.Modified = DateTime.Now; ctx.Entry(dbNote).CurrentValues.SetValues(note); await ctx.SaveChangesAsync(); //var dbNote = ctx.Notes.Find(note.Id); //dbNote.Lead = note.Lead; //dbNote.Modified = DateTime.Now; //dbNote.ShareLink = note.ShareLink; //dbNote.Title = note.Title; //return ctx.SaveChangesAsync(); } }
private NoteBrowsedRecordDAL() { this.dbContext = new MyNoteContext(); }
private NoteCommentDAL() { this.dbContext = new MyNoteContext(); }
private FtpConfigDAL() { this.dbContext = new MyNoteContext(); }
private SysInfoDAL() { this.dbContext = new MyNoteContext(); }
private NoteApprovedRecordDAL() { this.dbContext = new MyNoteContext(); }
private UserDAL() { this.dbContext = new MyNoteContext(); }
private VerificationDAL() { this.dbContext = new MyNoteContext(); }
public AuthRepository() { ctx = new MyNoteContext(); userManager = new UserManager <IdentityUser>(new UserStore <IdentityUser>(ctx)); }