Ejemplo n.º 1
0
 private void DisplayWelcomeMessage(User user)
 {
     Service service = new Service();
     Event welcomeMessage = new Event();
     welcomeMessage.Active = true;
     welcomeMessage.CreationTime = DateTime.Now;
     welcomeMessage.Description = "Welcome to doStuff, We are a event based social media! "
     + "You can make groups, events with friends! Here on the left is a plus sign which allows you to create a new event."
     + "To create a new group, please select the dropdown menu above! HAVE FUN! :)";
     welcomeMessage.Location = "doStuff();";
     welcomeMessage.Max = 1;
     welcomeMessage.Min = 1;
     welcomeMessage.Minutes = 11;
     welcomeMessage.Name = "Welcome!";
     welcomeMessage.OwnerId = user.UserID;
     welcomeMessage.Photo = "random";
     welcomeMessage.TimeOfEvent = DateTime.Now + new TimeSpan(0, welcomeMessage.Minutes, 0);
     service.CreateEvent(ref welcomeMessage);
     service.AnswerEvent(user.UserID, welcomeMessage.EventID, false);
 }
Ejemplo n.º 2
0
        public async Task<ActionResult> Register(RegisterViewModel model)
        {
            if (ModelState.IsValid)
            {
                var user = new ApplicationUser() { UserName = model.UserName };
                var result = await UserManager.CreateAsync(user, model.Password);
                if (result.Succeeded)
                {
                    await SignInAsync(user, isPersistent: false);

                    var service = new Service();
                    User register = new User();
                    register.Active = true;
                    register.BirthYear = model.BirthYear;
                    register.DisplayName = model.DisplayName;
                    register.Email = model.Email;
                    register.Gender = model.Gender;
                    register.UserName = model.UserName;
                    service.CreateUser(ref register);

                    DisplayWelcomeMessage(register);
                    return RedirectToAction("Index", "User");
                }
                else
                {
                    ModelState.AddModelError("UserName", "That username is already taken");
                    AddErrors(result);
                }
            }

            // If we got this far, something failed, redisplay form.
            return View(model);
        }
Ejemplo n.º 3
0
 public bool CreateUser(ref User user)
 {
     return database.CreateUser(ref user);
 }
Ejemplo 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);
        }
Ejemplo n.º 5
0
 public bool CreateUser(User user)
 {
     db.Users.Add(user);
     db.SaveChanges();
     return false;
 }
Ejemplo n.º 6
0
 bool Equal(User a, User b)
 {
     if(a == null && b == null)
     {
         return true;
     }
     if (a == null || b == null)
     {
         return false;
     }
     if (a.UserID != b.UserID)
     {
         return false;
     }
     if (a.Active != b.Active)
     {
         return false;
     }
     if (a.UserName != b.UserName)
     {
         return false;
     }
     if (a.DisplayName != b.DisplayName)
     {
         return false;
     }
     if (a.BirthYear != b.BirthYear)
     {
         return false;
     }
     if (a.Gender != b.Gender)
     {
         return false;
     }
     if (a.Email != b.Email)
     {
         return false;
     }
     return true;
 }
Ejemplo n.º 7
0
 public bool CreateUser(ref User user)
 {
     context.UserList.Add(user);
         context.SaveChanges();
         return true;
 }