//[Authorize(Roles = "Admin,Client")] public ActionResult MyProfile(bool status = false) { ViewBag.Result = "Failed"; if (status == true) { ViewBag.Result = "Succeeded"; } string UserId = User.Identity.GetUserId(); UserViewModel userdetails = generic.GetUserDetail(User.Identity.GetUserId()); ViewBag.UserId = userdetails.SubscriberId; ViewData["UserProfile"] = userdetails; ViewData["CompanyLogo"] = cms.GetCompanyLogo(userdetails.SubscriberId).FirstOrDefault(); //var plandetail = admin.GetUserplanDetails(userdetails.SubscriberId).Where(c => c.AddOnId == 3).FirstOrDefault(); //ViewData["plandetail"] = plandetail; var corporateprofiles = cms.GetCorporateProfile(UserId).FirstOrDefault(); if (corporateprofiles != null) { PopulateNationality(corporateprofiles.Nationality); } else { PopulateNationality(); } return(View(corporateprofiles)); }
private string GetDeptId(string UserId, string Role) { CMSManager cms = new CMSManager(); if (Role.Equals("Admin") || Role.Equals("Client") || Role.Equals("Administrator")) { return(cms.GetCorporateProfile(UserId).FirstOrDefault().DepartmentId); } return(string.Empty); }
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")); }
public string AddUserToDB(string Name, string Email, string Mobile, string Designation, string SubscriberId, string UpdatedBy) { try { bool res = false; //if (!admMgr.GetUserExists(Email, Mobile, "")) //{ string userName = admMgr.GenerateUserName(); var user = new ApplicationUser { UserName = userName, Email = Email, PhoneNumber = Mobile, EmailConfirmed = true }; var result = UserManager.Create(user, "changeme"); if (result.Succeeded) { //string ModuleAccess = "EMS"; string RoleId = "Employee"; //string Department = "FAC"; //bool ManagerLevel = false; var status = UserManager.AddToRole(user.Id, RoleId); string UserId = User.Identity.GetUserId(); var userDetail = generic.GetUserDetail(UserId); if (status.Succeeded) { // userId, employeeId, emplanelled, name, dob, gender, maritalStatus, alternateContact, alternateEmail, nationality, subscriberId, departmentId, // managerLevel, reportingAuthority, updatedBy, updatedOn, deactivated, fatherName, spouseName, emergencyContactName, // emergencyContactNumber, bloodGroup, physicallyChallenged, location, marriageDate, designationId) EmployeeView emp = new EmployeeView(); emp.UserId = user.Id; emp.EmployeeId = ""; emp.Emplanelled = false; emp.Name = Name; emp.Gender = ""; emp.DOB = DateTime.Now; emp.MaritalStatus = ""; emp.AlternateEmail = ""; emp.Nationality = ""; emp.DepartmentId = "FAC"; emp.ReportingAuthority = userDetail.SubscriberId; emp.UpdatedOn = DateTime.Now; emp.Deactivated = false; emp.FatherName = ""; emp.SpouseName = ""; emp.EmergencyContactName = ""; emp.EmergencyContactNumber = ""; emp.BloodGroup = ""; emp.Location = ""; emp.PhysicallyChallenged = false; emp.MarriageDate = DateTime.Now; emp.DesignationId = 64; emp.UpdatedBy = userDetail.SubscriberId; res = admMgr.AddEmployee(emp, userDetail.SubscriberId, UserId); var subscriberDetail = cms.GetCorporateProfile(SubscriberId).FirstOrDefault(); if (res) { SuccessCount++; Object[] data = new Object[8]; data[0] = Name; data[1] = Email; data[2] = Mobile; data[3] = result.Succeeded; //await SendEmailConfirmationTokenAsync(subscriberDetail.Name, user.Id, "Account activation", userName, Mobile, Name); } else { Object[] data = new Object[8]; data[0] = Name; data[1] = Email; data[2] = Mobile; data[3] = "Error"; resultedTable.Rows.Add(data); } } } else { FailureCount++; Object[] data = new Object[8]; data[0] = Name; data[1] = Email; data[2] = Mobile; data[3] = result.Succeeded; int i = 4; foreach (string err in result.Errors) { data[i] = err; i++; } resultedTable.Rows.Add(data); } //} //else //{ // FailureCount++; // Object[] data = new Object[8]; // data[0] = Name; // data[1] = Email; // data[2] = Mobile; // data[3] = "Failure"; // data[4] = "Email or Phone Number or Employee Code already exists"; // resultedTable.Rows.Add(data); //} } catch (Exception ex) { FailureCount++; Object[] data = new Object[8]; data[0] = Name; data[1] = Email; data[2] = Mobile; data[3] = "Failed"; data[4] = ex.Message; resultedTable.Rows.Add(data); } return("Result"); //return Json("Result", JsonRequestBehavior.AllowGet); }
private ActionResult RedirectToLocal(string returnUrl, string userId) { //if (Url.IsLocalUrl(returnUrl)) //{ // return Redirect(returnUrl); //} var roles = UserManager.GetRoles(userId); var roleId = roles.FirstOrDefault(); if (roleId.ToUpper() == "CANDIDATE") { return(RedirectToAction("Index", "Dashboard", new { area = "Candidate" })); } else if (roleId.ToUpper() == "EMPLOYEE") { return(RedirectToAction("MyTraining", "TMS", new { area = "TMS", TId = userId })); //return RedirectToAction("Index", "Dashboard", new { area = "EMS" }); } else if (roleId.ToUpper() == "ADMINISTRATOR") { return(RedirectToAction("Index", "Admin", new { area = "Admin" })); } var moduleAccess = admin.GetUserModuleAccess(userId, DateTime.UtcNow, roleId); if (moduleAccess != null) { if (moduleAccess.ModuleId.ToUpper() == "CMS") { if (roleId.ToUpper() == "ADMIN") { return(RedirectToAction("Index", "Dashboard", new { area = "CMS" })); } else if (roleId.ToUpper() == "CLIENT") { if (cmsmgr.GetCorporateProfile(userId).FirstOrDefault().DepartmentId.ToUpper() == "CLI") { return(RedirectToAction("Client", "Dashboard", new { area = "CMS" })); } else { return(RedirectToAction("Partner", "Dashboard", new { area = "CMS" })); } } else { return(RedirectToAction("Index", "Home")); } } else { return(RedirectToAction("Index", "Home")); } } else if (moduleAccess == null && roleId.ToUpper() == "CLIENT") { return(RedirectToAction("Client", "Dashboard", new { area = "CMS" })); } else { return(RedirectToAction("Index", "Home")); } }