Example #1
0
        public ActionResult CreateNewGroup(GroupViewModel s)
        {
            if (ModelState.IsValid)
            {
                var photoService     = new PhotoService(myDbContext);
                var groupService     = new GroupService(myDbContext);
                var groupListService = new GroupListService(myDbContext);
                var userService      = new UserService(myDbContext);


                Group g = new Group();

                g.Name        = s.Name;
                g.Creator     = userService.GetUser(User.Identity.GetUserId());
                g.Type        = Convert.ToInt32(s.Type);
                g.Description = s.Description;

                groupService.AddGroup(g);

                GroupList gl = new GroupList();

                gl.User  = g.Creator;
                gl.Group = g;

                groupListService.AddGroupToList(gl);

                return(RedirectToAction("Index"));
            }
            else
            {
                return(View(s));
            }
        }
Example #2
0
        public ActionResult JoinGroup(int Id)
        {
            var userService      = new UserService(myDbContext);
            var groupListService = new GroupListService(myDbContext);
            var userId           = User.Identity.GetUserId();
            var user             = userService.GetUser(userId);

            if (groupListService.getGroupList(Id, user) != null)
            {
                return(RedirectToAction("Index"));
            }

            var groupList    = new GroupList();
            var groupService = new GroupService(myDbContext);

            groupList.Group = groupService.GetGroup(Id);
            groupList.User  = user;
            groupListService.AddGroupToList(groupList);

            return(RedirectToAction("Index"));
        }