コード例 #1
0
        public bool AddNewRoom(GroopsRoom newRoom)
        {
            DataClassesContextDataContext db = new DataClassesContextDataContext();

            var thisRoom = new GroopsRoom();

            thisRoom.Name          = newRoom.Name;
            thisRoom.CreatorUserId = newRoom.CreatorUserId;
            thisRoom.ID            = newRoom.ID;


            db.GroopsRooms.InsertOnSubmit(thisRoom);

            //submit the changes to the database
            try
            {
                db.SubmitChanges();
                return(true);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
                return(false);
            }
        }
コード例 #2
0
        public GroopsRoom[] GetAllRooms()
        {
            //var ctx = HttpContext.Current;

            //if (ctx != null)
            //{
            //    return (GroopsAPI[])ctx.Cache[CacheKey];

            //}

            //return new GroopsAPI[]{

            //    new GroopsAPI{
            //        Id=0,
            //        Name = "Placeholder"
            //    }

            //};


            DataClassesContextDataContext db = new DataClassesContextDataContext();

            GroopsRoom[] allRooms = db.GroopsRooms.Select(x => x).ToArray();

            return(allRooms);
        }
コード例 #3
0
        public string  getRoomNameFromId(Guid roomId){
            DataClassesContextDataContext db = new DataClassesContextDataContext();
            string roomName = (from oneRoom in db.GroopsRooms
                               where oneRoom.ID == roomId
                               select oneRoom.Name).FirstOrDefault();

            return roomName;
        }
コード例 #4
0
        public string  getRoomNameFromId(Guid roomId)
        {
            DataClassesContextDataContext db = new DataClassesContextDataContext();
            string roomName = (from oneRoom in db.GroopsRooms
                               where oneRoom.ID == roomId
                               select oneRoom.Name).FirstOrDefault();

            return(roomName);
        }
コード例 #5
0
        private string userIdToUserName(Guid userId)
        {
            DataClassesContextDataContext db = new DataClassesContextDataContext();

            GroopsUser thisUser = (from oneUser in db.GroopsUsers
                                   where oneUser.ID == userId
                                   select oneUser).FirstOrDefault();

            // GroopsUser oneUserB = (GroopsUser) thisUser;



            return(thisUser.Name);
        }
コード例 #6
0
        public object[] getAllMessagesForRoom(Guid roomId)
        {
            DataClassesContextDataContext db = new DataClassesContextDataContext();

            object[] allMatchingMessages = (from oneMessage in db.GroopsMessages
                                            where oneMessage.RoomId == roomId
                                            select new
            {
                userName = userIdToUserName(oneMessage.UserId),
                message = oneMessage.Content,
            }).ToArray();

            return(allMatchingMessages);
        }
コード例 #7
0
        private string userIdToUserName(Guid userId)
        {
            DataClassesContextDataContext db = new DataClassesContextDataContext();

            GroopsUser thisUser = (from oneUser in db.GroopsUsers
                                   where oneUser.ID == userId
                                   select oneUser).FirstOrDefault();

            // GroopsUser oneUserB = (GroopsUser) thisUser;



            return thisUser.Name;
        }
コード例 #8
0
        public bool AddNewUser(GroopsUser oneGroopMember)
        {
            //var ctx = HttpContext.Current;
            //if (ctx != null)
            //{
            //    try
            //    {
            //        var currentData = ((GroopsAPI[])ctx.Cache[CacheKey]).ToList();
            //        currentData.Add(oneGroopMember);
            //        ctx.Cache[CacheKey] = currentData.ToArray();

            //        return true;
            //    }


            //    catch (Exception ex)
            //    {
            //        Console.WriteLine(ex.ToString());
            //        return false;
            //    }
            //}



            DataClassesContextDataContext db = new DataClassesContextDataContext();

            var thisUser = new GroopsUser();

            thisUser.Name  = oneGroopMember.Name;
            thisUser.Email = oneGroopMember.Email;
            thisUser.ID    = oneGroopMember.ID;

            db.GroopsUsers.InsertOnSubmit(thisUser);

            //submit the changes to the database
            try
            {
                db.SubmitChanges();
                return(true);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
                return(false);
            }
        }
コード例 #9
0
        public object[] getAllMessagesForRoom(Guid roomId)
        {


            DataClassesContextDataContext db = new DataClassesContextDataContext();
            object[] allMatchingMessages = (from oneMessage in db.GroopsMessages
                                            where oneMessage.RoomId == roomId
                                            select new
                                            {
                                                userName = userIdToUserName(oneMessage.UserId),
                                                message = oneMessage.Content,

                                            }).ToArray();

            return allMatchingMessages;



        }
コード例 #10
0
        public string addNewComment(Guid userId, string message, Guid roomId)
        {
            DataClassesContextDataContext db = new DataClassesContextDataContext();

            GroopsMessages thisMessage = new GroopsMessages();

            thisMessage.Content = message;
            thisMessage.ID      = Guid.NewGuid();
            thisMessage.RoomId  = roomId;
            thisMessage.UserId  = userId;
            thisMessage.Created = DateTime.Now;

            db.GroopsMessages.InsertOnSubmit(thisMessage);

            try
            {
                db.SubmitChanges();
                return(userIdToUserName(userId));
            }
            catch (Exception e)
            {
                return(null);
            }
        }
コード例 #11
0
        public string addNewComment(Guid userId, string message, Guid roomId)
        {
            DataClassesContextDataContext db = new DataClassesContextDataContext();

            GroopsMessages thisMessage = new GroopsMessages();

            thisMessage.Content = message;
            thisMessage.ID = Guid.NewGuid();
            thisMessage.RoomId = roomId;
            thisMessage.UserId = userId;
            thisMessage.Created = DateTime.Now;

            db.GroopsMessages.InsertOnSubmit(thisMessage);

            try
            {

                db.SubmitChanges();
                return userIdToUserName(userId);
            }
            catch (Exception e)
            {

                return null;
            }

        }
コード例 #12
0
        public bool AddNewUser(GroopsUser oneGroopMember)
        {
            //var ctx = HttpContext.Current;
            //if (ctx != null)
            //{
            //    try
            //    {
            //        var currentData = ((GroopsAPI[])ctx.Cache[CacheKey]).ToList();
            //        currentData.Add(oneGroopMember);
            //        ctx.Cache[CacheKey] = currentData.ToArray();

            //        return true;
            //    }


            //    catch (Exception ex)
            //    {
            //        Console.WriteLine(ex.ToString());
            //        return false;
            //    }
            //}



            DataClassesContextDataContext db = new DataClassesContextDataContext();

            var thisUser = new GroopsUser();

            thisUser.Name = oneGroopMember.Name;
            thisUser.Email = oneGroopMember.Email;
            thisUser.ID = oneGroopMember.ID;

            db.GroopsUsers.InsertOnSubmit(thisUser);

            //submit the changes to the database
            try
            {
                db.SubmitChanges();
                return true;
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
                return false;
            }


        }
コード例 #13
0
        public GroopsRoom[] GetAllRooms()
        {

            //var ctx = HttpContext.Current;

            //if (ctx != null)
            //{
            //    return (GroopsAPI[])ctx.Cache[CacheKey];

            //}

            //return new GroopsAPI[]{

            //    new GroopsAPI{
            //        Id=0,
            //        Name = "Placeholder"
            //    }

            //};


            DataClassesContextDataContext db = new DataClassesContextDataContext();
            GroopsRoom[] allRooms = db.GroopsRooms.Select(x => x).ToArray();

            return allRooms;


        }
コード例 #14
0
        public bool AddNewRoom(GroopsRoom newRoom)
        {

            DataClassesContextDataContext db = new DataClassesContextDataContext();

            var thisRoom = new GroopsRoom();

            thisRoom.Name = newRoom.Name;
            thisRoom.CreatorUserId = newRoom.CreatorUserId;
            thisRoom.ID = newRoom.ID;


            db.GroopsRooms.InsertOnSubmit(thisRoom);

            //submit the changes to the database
            try
            {
                db.SubmitChanges();
                return true;
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
                return false;
            }


        }