public async Task <ActionResult> AddTeamMember(string MemberId, string Name, string EmailId, string PhoneNumber, string Designation, IEnumerable <Int16> EmpRightsId, Int16 EmpRoleId = 0) { string CorporateId = User.Identity.GetUserId(); var UserDetail = generic.GetUserDetail(CorporateId); var ClientDetail = cms.GetCorporateProfile(CorporateId).FirstOrDefault(); if (String.IsNullOrEmpty(MemberId)) { //User Add Mode string userName = admin.GenerateUserName(); var user = new ApplicationUser { UserName = userName, Email = EmailId, PhoneNumber = PhoneNumber, EmailConfirmed = true }; var result = await UserManager.CreateAsync(user, "changeme"); if (result.Succeeded) { string RoleId = "Client"; var status = UserManager.AddToRole(user.Id, RoleId); if (status.Succeeded) { bool add = cms.AddTeamMember(user.Id, CorporateId, UserDetail.SubscriberId, Name, EmailId, PhoneNumber, EmpRoleId, Designation, DateTime.UtcNow, CorporateId); string callbackUrl = await SendEmailConfirmationTokenAsync(ClientDetail.Name, user.Id, "Account activation", userName, PhoneNumber, Name); } if (EmpRightsId != null) { foreach (var right in EmpRightsId) { var success = cms.AddTeamMemberRights(user.Id, right, DateTime.UtcNow, CorporateId); } } } } else { var regUser = UserManager.FindById(MemberId); if (regUser != null) { bool result = admin.UpdateUserEmailPhone(regUser.UserName, EmailId, PhoneNumber, true); bool add = cms.AddTeamMember(MemberId, CorporateId, UserDetail.SubscriberId, Name, EmailId, PhoneNumber, EmpRoleId, Designation, DateTime.UtcNow, CorporateId); } foreach (var right in EmpRightsId) { var success = cms.AddTeamMemberRights(MemberId, right, DateTime.UtcNow, CorporateId); } } return(RedirectToAction("AddTeamMember", "Client")); }