public User confirmRegistration(int userId, int confirmationCode) { using (var db = new PlanBeeDataContext()) { var user = db.userTable.Where(u => u.id == userId).FirstOrDefault(); if (user == null) { return(user); } if (user.code == confirmationCode) { user.confirmed = true; } else { user.confirmed = false; } db.SaveChanges(); return(user); } }
public SharedMeetings ShareMeeting(int sharedBy, int sharedTo, int meetingId) { Meeting project = getMeeting(meetingId); User user = getUser(sharedTo); if (project == null || user == null) { return(null); } using (var db = new PlanBeeDataContext()) { var sharedMeeting = db.sharedMeetingsTable.Where(x => x.sharedTo == sharedTo && x.meetingId == meetingId).FirstOrDefault(); if (sharedMeeting != null) { return(null); } } using (var db = new PlanBeeDataContext()) { var sharedMeeting = new SharedMeetings { sharedBy = sharedBy, sharedTo = sharedTo, meetingId = meetingId }; db.sharedMeetingsTable.Add(sharedMeeting); db.SaveChanges(); return(sharedMeeting); } }
public SharedProjects ShareProject(int sharedBy, int sharedTo, int projectId) { Project project = getProject(projectId); User user = getUser(sharedTo); if (project == null || user == null) { return(null); } using (var db = new PlanBeeDataContext()) { var sharedProject = db.sharedProjectsTable.Where(x => x.sharedTo == sharedTo && x.projectId == projectId).FirstOrDefault(); if (sharedProject != null) { return(null); } } using (var db = new PlanBeeDataContext()) { var sharedProject = new SharedProjects { sharedBy = sharedBy, sharedTo = sharedTo, projectId = projectId }; db.sharedProjectsTable.Add(sharedProject); db.SaveChanges(); return(sharedProject); } }
public User insertuser(string userName, string password, string email, int confirmationNumber) { using (var db = new PlanBeeDataContext()) { var user = db.userTable.Where(x => x.username.ToLower().Equals(userName.ToLower()) || x.email.ToLower().Equals(email.ToLower())).FirstOrDefault(); if (user != null) { return(null); } } using (var db = new PlanBeeDataContext()) { var user = new User { username = userName, password = password, email = email, code = confirmationNumber, confirmed = false }; db.userTable.Add(user); db.SaveChanges(); return(user); } }
public bool deleteMeeting(int meetingId) { bool delete = false; using (var db = new PlanBeeDataContext()) { var meetings = db.meetingTable.Where(v => v.id == meetingId); if (meetings != null) { db.meetingTable.RemoveRange(meetings); db.SaveChanges(); delete = true; } } return(delete); }
public User resertPasswordUsername(string username, string newPassword) { using (var db = new PlanBeeDataContext()) { var user = db.userTable.Where(u => u.username.Equals(username)).FirstOrDefault(); if (user == null) { return(user); } user.password = newPassword; db.SaveChanges(); return(user); } }
public Project insertProject(string projectName, int userID, string description) { using (var db = new PlanBeeDataContext()) { var project = new Project { name = projectName, userId = userID, createdAt = DateTime.Now, destription = description }; db.projectTable.Add(project); db.SaveChanges(); return(project); } }
public Meeting insertMeeting(int projectID, string meetingName, string notes, string decisions, string imagePath) { using (var db = new PlanBeeDataContext()) { var meeting = new Meeting { name = meetingName, projectId = projectID, notes = notes, decisions = decisions, createdAt = DateTime.Now, imagePath = imagePath }; db.meetingTable.Add(meeting); db.SaveChanges(); return(meeting); } }
public Meeting updateMeeting(int id, int projectID = -1, string meetingName = null, string notes = null, string decisions = null, string imagePath = null) { using (var db = new PlanBeeDataContext()) { var meeting = db.meetingTable.Where(m => m.id == id).FirstOrDefault(); if (meeting == null) { return(null); } if (projectID != -1) { meeting.projectId = projectID; } if (meetingName != null && !meetingName.Equals(null)) { meeting.name = meetingName; } if (notes != null && !notes.Equals(null)) { meeting.notes = notes; } if (decisions != null && !decisions.Equals(null)) { meeting.decisions = decisions; } if (imagePath != null) { meeting.imagePath = imagePath; } db.SaveChanges(); return(meeting); } }
public bool deleleProject(int projectId) { bool delete = false; using (var db = new PlanBeeDataContext()) { var project = db.projectTable.Where(m => m.id == projectId).SingleOrDefault(); if (project != null) { db.projectTable.Remove(project); db.SaveChanges(); delete = true; } using (var dbs = new PlanBeeDataContext()) { var meetings = dbs.meetingTable.Where(v => v.projectId == projectId); if (meetings != null) { dbs.meetingTable.RemoveRange(meetings); dbs.SaveChanges(); delete = true; } } using (var dbs = new PlanBeeDataContext()) { var sharedprojects = dbs.sharedProjectsTable.Where(v => v.projectId == projectId); if (sharedprojects != null) { dbs.sharedProjectsTable.RemoveRange(sharedprojects); dbs.SaveChanges(); delete = true; } } return(delete); } }