public static bool DeleteNote(long NoteId) { bool result = false; try { WNDataContext db = new WNDataContext(); db.Notes.DeleteOnSubmit(db.Notes.Single(n => n.id == NoteId)); db.SubmitChanges(); result = true; } catch { result = false; } return result; }
public static bool DeleteNote(long NoteId) { bool result = false; try { WNDataContext db = new WNDataContext(); db.Notes.DeleteOnSubmit(db.Notes.Single(n => n.id == NoteId)); db.SubmitChanges(); result = true; } catch { result = false; } return(result); }
public static bool EditNote(long NoteId, long UserId, string Title,bool isPublic, string Tag, string NoteText) { bool result = false; try { WNDataContext db = new WNDataContext(); Note note = db.Notes.Single(n => n.id == NoteId); note.title = Title; note.isPublic = isPublic; note.content = NoteText; note.last_update = DateTime.Now; db.SubmitChanges(); result = true; } catch { result = false; } return result; }
public static long AddUser(string email, string password) { long userId; WNDataContext db = new WNDataContext(); User user = new User(); user.Email = email; user.Name = email.Split('@').Length>0?email.Split('@')[0]:"*"; user.Password = EncDec.Encrypt(password, "webnote"); UserRole uroles = new UserRole(); uroles.User = user; uroles.RoleId = 1; db.UserRoles.InsertOnSubmit(uroles); db.SubmitChanges(); userId = user.Id; return userId; }
public static bool EditNote(long NoteId, long UserId, string Title, bool isPublic, string Tag, string NoteText) { bool result = false; try { WNDataContext db = new WNDataContext(); Note note = db.Notes.Single(n => n.id == NoteId); note.title = Title; note.isPublic = isPublic; note.content = NoteText; note.last_update = DateTime.Now; db.SubmitChanges(); result = true; } catch { result = false; } return(result); }
public static long AddUser(string email, string password) { long userId; WNDataContext db = new WNDataContext(); User user = new User(); user.Email = email; user.Name = email.Split('@').Length > 0?email.Split('@')[0]:"*"; user.Password = EncDec.Encrypt(password, "webnote"); UserRole uroles = new UserRole(); uroles.User = user; uroles.RoleId = 1; db.UserRoles.InsertOnSubmit(uroles); db.SubmitChanges(); userId = user.Id; return(userId); }
public static bool AdNote(long userId, string title, bool isPublic, string tag, string content) { try { WNDataContext db = new WNDataContext(); Note note = new Note(); note.user_Id = userId; note.title = title; note.isPublic = isPublic; note.content = content; note.creation_date = DateTime.Now; note.last_update = DateTime.Now; db.Notes.InsertOnSubmit(note); db.SubmitChanges(); return true; } catch (Exception e) { //TODO: log error -> medium return false; } }
public static bool AdNote(long userId, string title, bool isPublic, string tag, string content) { try { WNDataContext db = new WNDataContext(); Note note = new Note(); note.user_Id = userId; note.title = title; note.isPublic = isPublic; note.content = content; note.creation_date = DateTime.Now; note.last_update = DateTime.Now; db.Notes.InsertOnSubmit(note); db.SubmitChanges(); return(true); } catch (Exception e) { //TODO: log error -> medium return(false); } }