Esempio n. 1
0
 public bool doesEmailExist(string email)
 {
     using (muleEntities db = new muleEntities())
     {
         return(db.users.Where(o => o.email.Equals(email)).Any());
     }
 }
Esempio n. 2
0
 public bool doesGroupExist(string name)
 {
     using (muleEntities db = new muleEntities())
     {
         return(db.groups.Where(o => o.group_name.Equals(name)).Any());
     }
 }
Esempio n. 3
0
        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();
            }
        }
Esempio n. 4
0
 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());
     }
 }
Esempio n. 5
0
 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());
     }
 }
Esempio n. 6
0
        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();
            }
        }
Esempio n. 7
0
        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();
                }
            }
        }
Esempio n. 8
0
        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();
            }
        }
Esempio n. 9
0
 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("");
         }
     }
 }
Esempio n. 10
0
 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);
         }
     }
 }
Esempio n. 11
0
 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);
         }
     }
 }
Esempio n. 12
0
 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);
         }
     }
 }
Esempio n. 13
0
 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);
         }
     }
 }
Esempio n. 14
0
        // 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();
            }
        }
Esempio n. 15
0
        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();
            }
        }
Esempio n. 16
0
        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();
                }
            }
        }