public void UpdateInvitePrivateUser(string UserId, string UserEmail, int id)
        {
            PrivateGroupUsers _CurrentPrivateGroupUser = context.PrivateGroupUsers.Where(i => i.id == id).FirstOrDefault();

            _CurrentPrivateGroupUser.UserId = UserId;
            _CurrentPrivateGroupUser.Email  = UserEmail;
            context.Entry(_CurrentPrivateGroupUser).State = System.Data.Entity.EntityState.Modified;
            context.SaveChanges();
        }
Beispiel #2
0
        public JsonResult InviteOthersToPrivateBunch(InviteOthersToPrivateBunchModel _InviteOthersToPrivateBunchModel)
        {
            var currentUser = idb.Users.Find(User.Identity.GetUserId());

            if (_InviteOthersToPrivateBunchModel.InviteUsers != null)
            {
                Task T = new Task(() =>
                {
                    UserHelper _UserHelp = new UserHelper();
                    Group _Group         = repository.GetGroupByID(_InviteOthersToPrivateBunchModel.GroupId);
                    List <PrivateGroupUsers> _PrivateGroupUsersList = new List <PrivateGroupUsers>();
                    List <string> UserNames = new List <string>();
                    foreach (InviteUser item in _InviteOthersToPrivateBunchModel.InviteUsers)
                    {
                        UserNames.Add(item.UserName);

                        if (_UserHelp.IsValidUserName(item.UserName))
                        {
                            var _User = idb.Users.Where(g => g.UserName == item.UserName).FirstOrDefault();
                            PrivateGroupUsers _PrivateGroupUsers = new PrivateGroupUsers
                            {
                                GroupId = _InviteOthersToPrivateBunchModel.GroupId,
                                Email   = _User.Email,
                                UserId  = _User.Id
                            };
                            _PrivateGroupUsersList.Add(_PrivateGroupUsers);
                        }
                        else
                        {
                            PrivateGroupUsers _PrivateGroupUsers = new PrivateGroupUsers
                            {
                                GroupId = _InviteOthersToPrivateBunchModel.GroupId,
                                Email   = item.UserName,
                            };
                            _PrivateGroupUsersList.Add(_PrivateGroupUsers);
                        }
                    }

                    repository.AddPrivateGroupInvite(_PrivateGroupUsersList);
                    repository.Save();

                    _UserHelp.SendUsersPrivateBunchInviteEmail(_PrivateGroupUsersList,
                                                               _InviteOthersToPrivateBunchModel.GroupId,
                                                               currentUser.UserName,
                                                               _Group.name);
                });

                T.Start();
            }

            return(Json(new
            {
                success = true,
                message = "Emails Sent",
                GroupId = _InviteOthersToPrivateBunchModel.GroupId
            }, JsonRequestBehavior.AllowGet));
        }