public bool doesEmailExist(string email) { using (muleEntities db = new muleEntities()) { return(db.users.Where(o => o.email.Equals(email)).Any()); } }
public bool doesGroupExist(string name) { using (muleEntities db = new muleEntities()) { return(db.groups.Where(o => o.group_name.Equals(name)).Any()); } }
public void AddGroup(group g, string email) { UserManager UM = new UserManager(); int id = UM.getUserId(email); using (muleEntities db = new muleEntities()) { group ng = new group(); ng.user_owner_id = id; ng.group_name = g.group_name; ng.description = g.description; ng.private_flag = 0; db.groups.Add(ng); db.SaveChanges(); user_group ug = new user_group(); ug.group_id = getGroupId(g.group_name); ug.user_id = id; ug.is_approved = 1; db.user_group.Add(ug); db.SaveChanges(); } }
public bool checkMembership(int u_id, int g_id) { using (muleEntities db = new muleEntities()) { return(db.user_group.Where(o => (o.group_id.Equals(g_id) && o.user_id.Equals(u_id))).Any()); } }
public bool checkActive(int u_id, int g_id) { using (muleEntities db = new muleEntities()) { return(db.user_group.Where(o => (o.group_id.Equals(g_id) && o.user_id.Equals(u_id) && o.is_approved == 1)).Any()); } }
public void AddComment(int post_id, int user_id, String commentTA) { using (muleEntities db = new muleEntities()) { comment nc = new comment(); nc.comment_date = DateTime.Now; nc.comment1 = commentTA; nc.user_id = user_id; nc.post_id = post_id; db.comments.Add(nc); db.SaveChanges(); } }
public void declineMember(int u_id, int g_id) { using (muleEntities db = new muleEntities()) { var record = db.user_group.FirstOrDefault(m => m.group_id == g_id && m.user_id == u_id); if (record != null) { db.user_group.Remove(record); db.SaveChanges(); } } }
public void approveMember(int u_id, int g_id) { using (muleEntities db = new muleEntities()) { var record = db.user_group.Where(x => x.user_id.Equals(u_id) && x.group_id.Equals(g_id)).FirstOrDefault(); if (record != null) { record.is_approved = 1; } db.SaveChanges(); } }
public String getUserPassword(string email) { using (muleEntities db = new muleEntities()) { var user = db.users.Where(o => o.email.ToLower().Equals(email)); if (user.Any()) { return(user.FirstOrDefault().password); } else { return(""); } } }
public int getUserId(string email) { using (muleEntities db = new muleEntities()) { var user = db.users.Where(o => o.email.Equals(email)); if (user.Any()) { return(user.FirstOrDefault().user_id); } else { return(-1); } } }
public int getGroupId(string name) { using (muleEntities db = new muleEntities()) { var group = db.groups.Where(o => o.group_name.ToLower().Equals(name)); if (group.Any()) { return(group.FirstOrDefault().group_id); } else { return(-1); } } }
public group getGroup(int id) { using (muleEntities db = new muleEntities()) { var group = db.groups.Where(o => o.group_id.Equals(id)); if (group.Any()) { return(group.FirstOrDefault()); } else { return(null); } } }
public post getPost(int id) { using (muleEntities db = new muleEntities()) { var post = db.posts.Where(o => o.post_id.Equals(id)); if (post.Any()) { return(post.FirstOrDefault()); } else { return(null); } } }
// http://proudmonkey.azurewebsites.net/building-web-application-using-entity-framework-and-mvc-5-part-1/ public void AddUserAccount(user u) { using (muleEntities db = new muleEntities()) { user nu = new user(); nu.first_name = u.first_name; nu.last_name = u.last_name; nu.email = u.email; nu.password = sha256_hash(u.password); nu.confirm_password = "******"; nu.is_premium = 1; db.users.Add(nu); db.SaveChanges(); } }
public void AddMember(group g, string email) { UserManager UM = new UserManager(); int id = UM.getUserId(email); using (muleEntities db = new muleEntities()) { user_group nug = new user_group(); nug.group_id = g.group_id; nug.user_id = id; nug.is_approved = 0; db.user_group.Add(nug); db.SaveChanges(); } }
public void RemoveMember(group g, string email) { UserManager UM = new UserManager(); int id = UM.getUserId(email); using (muleEntities db = new muleEntities()) { var record = db.user_group.FirstOrDefault(m => m.group_id == g.group_id && m.user_id == id); if (record != null) { db.user_group.Remove(record); db.SaveChanges(); } } }