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 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(); } }
// 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(); } } }