Exemplo n.º 1
0
 public bool CreateGroup(ref Group group)
 {
     if (database.CreateGroup(ref group))
     {
         GroupToUserRelation relation = new GroupToUserRelation();
         relation.GroupId = group.GroupID;
         relation.MemberId = group.OwnerId;
         relation.Active = true;
         database.CreateGroupToUserRelation(ref relation);
         return true;
     }
     return false;
 }
Exemplo n.º 2
0
 public ActionResult CreateGroup(string name)
 {
     var service = new Service();
     User user = service.GetUser(User.Identity.Name);
     if (String.IsNullOrEmpty(name))
     {
         TempData["message"] = new Message("Group name can not be empty.", MessageType.ERROR);
         return RedirectToAction("CreateGroup");
     }
     Group group = new Group(true, user.UserID, name, 0);
     if (service.CreateGroup(ref group))
     {
         TempData["message"] = new Message("Your group was created!", MessageType.SUCCESS);
         return RedirectToAction("Index", new { groupId = group.GroupID });
     }
     TempData["message"] = new Message("Your group could not be created, please try again later.", MessageType.ERROR);
     return RedirectToAction("Index");
 }
Exemplo n.º 3
0
 bool Equal(Group a, Group b)
 {
     if (a == null && b == null)
     {
         return true;
     }
     if (a == null || b == null)
     {
         return false;
     }
     if(a.GroupID != b.GroupID)
     {
         return false;
     }
     if(a.Active != b.Active)
     {
         return false;
     }
     if(a.OwnerId != b.OwnerId)
     {
         return false;
     }
     if(a.Name != b.Name)
     {
         return false;
     }
     return true;
 }
Exemplo n.º 4
0
        public void Initialize()
        {
            MockDb mock = new MockDb();

            #region Users
            User user1 = new User
            {
                UserID = 1,
                Active = true,
                UserName = "******",
                DisplayName = "xXx$w4gM4$t3r420xXx",
                BirthYear = 9000,
                Gender = Gender.MALE,
                Email = "[email protected]"
            };
            User user2 = new User
            {
                UserID = 2,
                Active = true,
                UserName = "******",
                DisplayName = "Sultumenni500",
                BirthYear = 1337,
                Gender = Gender.MALE,
                Email = "*****@*****.**"
            };
            User user3 = new User
            {
                UserID = 3,
                Active = true,
                UserName = "******",
                DisplayName = "Pulsmeister99",
                BirthYear = 9000,
                Gender = Gender.FEMALE,
                Email = "*****@*****.**"
            };
            mock.UserList.Add(user1);
            mock.UserList.Add(user2);
            mock.UserList.Add(user3);
            #endregion
            #region Groups

            Group group1 = new Group
            {
                GroupID = 1,
                Active = true,
                OwnerId = 1,
                Name = "Team Gulli"
            };
            Group group2 = new Group
            {
                GroupID = 2,
                Active = true,
                OwnerId = 3,
                Name = "Pulsuvagninn"
            };
            mock.Groups.Add(group1);
            mock.Groups.Add(group2);
            #endregion
            #region Events
            Event event1 = new Event
            {
                EventID = 1,
                Active = true,
                GroupId = null,
                OwnerId = 1,
                Name = "Lan",
                Photo = "",
                Description = "Quake 4 lyfe",
                CreationTime = new DateTime(2015, 5, 6, 12, 30, 1),
                TimeOfEvent = new DateTime(2015, 5, 9, 12, 30, 0),
                Minutes = 60,
                Location = "the internet",
                Min = 0,
                Max = 5,
            };

            Event event2 = new Event
            {
                EventID = 2,
                Active = true,
                GroupId = 2,
                OwnerId = 3,
                Name = "Pulsuparty",
                Photo = "",
                Description = "pulsulíf",
                CreationTime = new DateTime(2015, 5, 6, 12, 30, 1),
                TimeOfEvent = new DateTime(2015, 5, 9, 12, 30, 0),
                Minutes = 60,
                Location = "bæjarins bestu",
                Min = 0,
                Max = 5,
            };
            mock.Events.Add(event1);
            mock.Events.Add(event2);

            #endregion
            #region Comments
            Comment comment1 = new Comment
            {
                CommentID = 1,
                Active = true,
                OwnerId = 2,
                Content = "FOKK PULSUR, SULTA IS SUPERIOR",
                CreationTime = new DateTime(2015, 5, 6, 12, 35, 1)
            };
            mock.Comments.Add(comment1);

            #endregion
            #region GroupToUserRelations
            GroupToUserRelation groupUser1 = new GroupToUserRelation
            {
                GroupToUserRelationID = 1,
                Active = true,
                GroupId = 1,
                MemberId = 1
            };

            GroupToUserRelation groupUser2 = new GroupToUserRelation
            {
                GroupToUserRelationID = 2,
                Active = true,
                GroupId = 2,
                MemberId = 3
            };

            GroupToUserRelation groupUser3 = new GroupToUserRelation
            {
                GroupToUserRelationID = 3,
                Active = true,
                GroupId = 2,
                MemberId = 2
            };

            GroupToUserRelation groupUser4 = new GroupToUserRelation
            {
                GroupToUserRelationID = 4,
                Active = true,
                GroupId = 1,
                MemberId = 2
            };
            mock.GroupToUserRelations.Add(groupUser1);
            mock.GroupToUserRelations.Add(groupUser2);
            mock.GroupToUserRelations.Add(groupUser3);
            mock.GroupToUserRelations.Add(groupUser4);

            #endregion
            #region GroupsToEventRelations
            GroupToEventRelation groupEvent1 = new GroupToEventRelation
            {
                GroupToEventRelationID = 1,
                Active = true,
                EventId = 2,
                GroupId = 2
            };
            mock.GroupToEventRelations.Add(groupEvent1);

            #endregion
            #region UserToUserRelations

            UserToUserRelation friendship1 = new UserToUserRelation
            {
                UserToUserRelationID = 1,
                Active = true,
                SenderId = 2,
                ReceiverId = 3,
                Answer = true
            };

            UserToUserRelation friendship2 = new UserToUserRelation
            {
                UserToUserRelationID = 2,
                Active = true,
                SenderId = 1,
                ReceiverId = 2,
                Answer = true
            };

            mock.UserToUserRelations.Add(friendship1);
            mock.UserToUserRelations.Add(friendship2);

            #endregion
            #region EventToUserRelations

            EventToUserRelation eventUser1 = new EventToUserRelation
            {
                EventToUserRelationID = 1,
                Active = true,
                EventId = 1,
                AttendeeId = 1,
                Answer = true
            };

            EventToUserRelation eventUser2 = new EventToUserRelation
            {
                EventToUserRelationID = 2,
                Active = true,
                EventId = 1,
                AttendeeId = 2,
                Answer = null
            };

            EventToUserRelation eventUser3 = new EventToUserRelation
            {
                EventToUserRelationID = 3,
                Active = true,
                EventId = 2,
                AttendeeId = 3,
                Answer = true
            };

            EventToUserRelation eventUser4 = new EventToUserRelation
            {
                EventToUserRelationID = 4,
                Active = true,
                EventId = 2,
                AttendeeId = 2,
                Answer = false
            };

            mock.EventToUserRelations.Add(eventUser1);
            mock.EventToUserRelations.Add(eventUser2);
            mock.EventToUserRelations.Add(eventUser3);
            mock.EventToUserRelations.Add(eventUser4);

            #endregion
            #region EventToCommentRelations

            EventToCommentRelation eventComment1 = new EventToCommentRelation
            {
                EventToCommentRelationID = 1,
                EventId = 2,
                CommentId = 1,
                Active = true

            };

            mock.EventToCommentRelations.Add(eventComment1);
            #endregion

            DbTest = new Database(mock);
            ServiceTest = new Service(DbTest);
        }
Exemplo n.º 5
0
 public bool CreateGroup(ref Group group)
 {
     context.Groups.Add(group);
         context.SaveChanges();
         return true;
 }