//[Authorize(Roles = "Employee,Admin")] public async Task <ActionResult> Add(InstructorLeadProfileView instructor, string[] Qualification , string[] Domain, string[] Organization, string[] LanguageKnown, string[] Specialization, string[] NibfProject, HttpPostedFileBase uploadPhoto, string UserAction, string fileName, string InstructorId, int TrainnerCity = 0) { string UserId = User.Identity.GetUserId(); UserViewModel userDetails = generic.GetUserDetail(UserId); bool Empanelled = false; // string UpdatedBy = User.Identity.GetUserId(); var RStatus = ""; //foreach (string file in Request.Files) //{ // HttpPostedFileBase attachment = Request.Files[file] as HttpPostedFileBase; // //tms.uploadFile(TrainingId, attachment); //} if (UserAction == "Edit") { instructor.InstructorId = InstructorId; //instructor.CityId = TrainnerCity; if (Qualification != null) { instructor.Qualification = string.Join(",", Qualification); foreach (string item in Qualification) { var qualification = db.QualificationMaster.Where(q => q.Qualification.Contains(item)).Count(); if (qualification == 0) { cms.AddQualification(item); } } } if (Domain != null) { instructor.DomainExpertize = string.Join(",", Domain); foreach (string item in Domain) { var domainexpertize = db.DomainMaster.Where(q => q.Domain.Contains(item)).Count(); if (domainexpertize == 0) { cms.AddDomain(item); } } } if (Organization != null) { instructor.Organization = string.Join(",", Organization); foreach (string item in Organization) { var organization = db.OrganizationMaster.Where(q => q.Organization.Contains(item)).Count(); if (organization == 0) { cms.AddOrganization(item); } } } if (LanguageKnown != null) { instructor.LanguageKnown = string.Join(",", LanguageKnown); } if (Specialization != null) { foreach (string item in Specialization) { var specialization = db.SpecializationMaster.Where(q => q.Specialization.Contains(item)).Count(); if (specialization == 0) { cms.Addspecialization(item); } } instructor.Specialization = string.Join(",", Specialization); } if (NibfProject != null) { foreach (string item in NibfProject) { var project = db.ProjectMaster.Where(q => q.Project.Contains(item)).Count(); if (project == 0) { cms.Addproject(item); } } instructor.NibfProject = string.Join(",", NibfProject); } instructor.Empanelled = Empanelled; instructor.SubscriberId = userDetails.SubscriberId; instructor.UpdatedBy = UserId; bool res = cms.AddInstructorLeadProfile(instructor, uploadPhoto); } else { string RoleId = "Employee"; //string savestatus = ""; // if (employee.UserId == null) { var EmailExists = admin.GetLoginDetails(instructor.Email); var instructorleads = cms.GetInstructerLead(userDetails.SubscriberId); InstructorLeadProfileView instructorexist = new InstructorLeadProfileView(); if (EmailExists != null) { instructorexist = instructorleads.Where(i => i.InstructorId == EmailExists.Id).FirstOrDefault(); } if (EmailExists != null && instructorleads == null) { instructor.InstructorId = EmailExists.Id; //RStatus = "EmailId Exist"; // return Json("EmailExists", JsonRequestBehavior.AllowGet); if (Qualification != null) { instructor.Qualification = string.Join(",", Qualification); foreach (string item in Qualification) { var qualification = db.QualificationMaster.Where(q => q.Qualification.Contains(item)).Count(); if (qualification == 0) { cms.AddQualification(item); } } } if (Domain != null) { instructor.DomainExpertize = string.Join(",", Domain); foreach (string item in Domain) { var domainexpertize = db.DomainMaster.Where(q => q.Domain.Contains(item)).Count(); if (domainexpertize == 0) { cms.AddDomain(item); } } } if (Organization != null) { instructor.Organization = string.Join(",", Organization); foreach (string item in Organization) { var organization = db.OrganizationMaster.Where(q => q.Organization.Contains(item)).Count(); if (organization == 0) { cms.AddOrganization(item); } } } if (LanguageKnown != null) { instructor.LanguageKnown = string.Join(",", LanguageKnown); } if (Specialization != null) { foreach (string item in Specialization) { var specialization = db.SpecializationMaster.Where(q => q.Specialization.Contains(item)).Count(); if (specialization == 0) { cms.Addspecialization(item); } } instructor.Specialization = string.Join(",", Specialization); } if (NibfProject != null) { foreach (string item in NibfProject) { var project = db.ProjectMaster.Where(q => q.Project.Contains(item)).Count(); if (project == 0) { cms.Addproject(item); } } instructor.NibfProject = string.Join(",", NibfProject); } instructor.Empanelled = Empanelled; instructor.SubscriberId = userDetails.SubscriberId; instructor.UpdatedBy = UserId; instructor.CityId = TrainnerCity; bool res = cms.AddInstructorLeadProfile(instructor, uploadPhoto); } else { var user = new ApplicationUser { UserName = instructor.Email, Email = instructor.Email, PhoneNumber = instructor.PhoneNumber, EmailConfirmed = true }; var result = await UserManager.CreateAsync(user, "changeme"); var status = UserManager.AddToRole(user.Id, RoleId); instructor.InstructorId = user.Id; if (status.Succeeded) { //savestatus = "Succeeded"; //bool res = admin.AddEmployee(emp, UserId, UpdatedBy); //if (RoleId.ToUpper() == "EMPLOYEE") // emsMgr.AddProfileTypeDetails(0, user.Id, "Default"); ////Sending Email To User //string callbackUrl = await SendEmailConfirmationTokenAsync(subscriberDetail.Name, user.Id, "Account activation", userName, emp.AlternateContact, emp.Name); //Sending SMS To User //string mobile = emp.AlternateContact; //string message1 = "Hello" + emp.Name + ", you are added as a Employee in RECKONN by " + generic.GetUserDetail(userDetail.SubscriberId).Name; //generic.sendSMSMessage(message1, mobile); if (Qualification != null) { instructor.Qualification = string.Join(",", Qualification); foreach (string item in Qualification) { var qualification = db.QualificationMaster.Where(q => q.Qualification.Contains(item)).Count(); if (qualification == 0) { cms.AddQualification(item); } } } if (Domain != null) { instructor.DomainExpertize = string.Join(",", Domain); foreach (string item in Domain) { var domainexpertize = db.DomainMaster.Where(q => q.Domain.Contains(item)).Count(); if (domainexpertize == 0) { cms.AddDomain(item); } } } if (Organization != null) { instructor.Organization = string.Join(",", Organization); foreach (string item in Organization) { var organization = db.OrganizationMaster.Where(q => q.Organization.Contains(item)).Count(); if (organization == 0) { cms.AddOrganization(item); } } } if (LanguageKnown != null) { instructor.LanguageKnown = string.Join(",", LanguageKnown); } if (Specialization != null) { foreach (string item in Specialization) { var specialization = db.SpecializationMaster.Where(q => q.Specialization.Contains(item)).Count(); if (specialization == 0) { cms.Addspecialization(item); } } instructor.Specialization = string.Join(",", Specialization); } if (NibfProject != null) { foreach (string item in NibfProject) { var project = db.ProjectMaster.Where(q => q.Project.Contains(item)).Count(); if (project == 0) { cms.Addproject(item); } } instructor.NibfProject = string.Join(",", NibfProject); } instructor.Empanelled = Empanelled; instructor.SubscriberId = userDetails.SubscriberId; instructor.UpdatedBy = UserId; instructor.CityId = TrainnerCity; bool res = cms.AddInstructorLeadProfile(instructor, uploadPhoto); } } } return(RedirectToAction("Add", "Trainer", new { area = "CMS", Status = RStatus })); }