public async Task <IActionResult> NewGroupStep3(NewGroupStep3ViewModel model)
        {
            ViewData["Id"] = model.UserId;

            AppUser user = await userManager.FindByIdAsync(model.UserId);

            if (user != null)
            {
                //group
                Group group = repository.Groups
                              .FirstOrDefault(g => g.GroupId == model.GroupId);

                if (model.CoursesIdString != null)
                {
                    //list of users id
                    string courseIdList = model.CoursesIdString.Trim();
                    while (courseIdList.Trim().Length > 0)
                    {
                        int index = courseIdList.IndexOf(";");
                        if (index != -1)
                        {
                            string newCourseId = courseIdList.Substring(0, index);

                            int newCourseIdInt = Int32.Parse(newCourseId.Trim());

                            repository.AddCourseToGroup(newCourseIdInt, group.GroupId);

                            courseIdList = courseIdList.Replace(newCourseId + ";", "");
                        }
                    }
                }

                //send msg
                if (group.GroupChatId != 0)
                {
                    GroupChat groupChat = repository.GroupChats
                                          .FirstOrDefault(g => g.ChatId == group.GroupChatId);

                    string userName = (user.FirstName == null && user.LastName == null) ?
                                      user.UserName : user.FirstName + user.LastName;
                    string           content = $"{userName} created a group chat";
                    GroupChatMessage newMsg  = new GroupChatMessage
                    {
                        GroupChatId    = group.GroupChatId,
                        UserId         = user.Id,
                        MessageContent = content,
                        MessageType    = "SystemMsg"
                    };

                    repository.NewGroupChatMessage(newMsg, groupChat);
                }

                //new notification
                if (group.Status == "Public")
                {
                    repository.NewNotification(user.Id, "AddUserToGroup", "Group", group.GroupId);
                }

                return(RedirectToAction("GroupDetails", new
                {
                    id = group.CreatedBy.Id,
                    groupId = group.GroupId
                }));
            }

            return(RedirectToAction("Error", "UserNotFound"));
        }