public ActionResult AllApplications(ComFeedBack model) { obj = GetData(); int marks = 0; if (model.Performance == "Poor") { marks = 0; } else if (model.Performance == "Fair") { marks = 25; } else if (model.Performance == "Average") { marks = 50; } else if (model.Performance == "Good") { marks = 75; } else if (model.Performance == "Excellent") { marks = 100; } db.BI_insert_com_member_feedback(model.InstituteId, Convert.ToInt32(obj.Institute_Id), model.CheckName, marks, model.Recommendation, obj.Application_id, obj.Affiliation_Year); db.SaveChanges(); ComMembers.Application_id = model.InstituteId; var dbinstitutes = db.BI_Affi_ins_pop_visited_institute(Convert.ToInt32(obj.Institute_Id)).ToList(); ComFeedBack comfb = new ComFeedBack(); string[] instituteName = new string[4] { "Faculty", "Labortries", "Library", "Other" }; List <DDLComMemberCheckPoint> checklist = new List <DDLComMemberCheckPoint>(); List <InstituteForMembersAllApplications> ifmlist = new List <InstituteForMembersAllApplications>(); foreach (var ins in dbinstitutes) { InstituteForMembersAllApplications ifm = new InstituteForMembersAllApplications(); ifm.InstituteId = Convert.ToInt32(ins.Institute_ID); ifm.InstituteName = ins.Institute_Name; ifmlist.Add(ifm); } for (var i = 0; i < instituteName.Length; i++) { DDLComMemberCheckPoint ddl = new DDLComMemberCheckPoint(); ddl.CheckName = instituteName[i]; checklist.Add(ddl); } comfb.InstitutesDDL = ifmlist; comfb.CheckPoint = checklist; return(View(comfb)); }
//Add & Edit COmmittee Member public async Task<ActionResult> CreateCommitteeMember(AffiliationCommitteeMember model) { if (!ModelState.IsValid) { var Asdesignation = db.Affi_com_Designation.ToList(); model.AsMember = Asdesignation; TempData["ModelState"] = "Check The Entered Information"; if (model.UserId == null) return View("AffiliationCommittee", model); else if (model.UserId != null) return View("EditCommitteeMember", model); } try { //var UserStore = new UserStore<ApplicationUser>(new ApplicationDbContext()); //var UserManager = new UserManager<ApplicationUser>(UserStore); if (model.UserId == null) { var User = new ApplicationUser() { UserName = model.UserName, UserType = 11, isDisable = false, PhoneNumber=model.ACMember.Cell, Email = model.Email }; var result = await UserManager.CreateAsync(User, model.Password); if (result.Succeeded) { await UserManager.AddToRoleAsync(User.Id, "Member"); //TempData["CreateCommitteeMember"] = model; //TempData["ReturnUrl"] = "/AffiliationAdminSide/CreateCommitteeMemberAfterTwoFactorRegister"; //return RedirectToAction("VerifyCellNo", "Accounts", new { PhoneNumber = model.ACMember.Cell, UserId = User.Id }); var asdesignation = db.BI_affi_pop_affi_com_designation(); foreach (var member in asdesignation) { if (model.ACMember.com_designation_ID == member.ID) { model.ACMember.As_Com_Designation = member.Designation; } } if (model.ACMember.ID == null) { ObjectParameter output = new ObjectParameter("UserId", typeof(Int32)); db.TA3_affi_Create_affiliation_com(model.ACMember.Name, model.ACMember.Designation, model.ACMember.As_Com_Designation, model.ACMember.Department, model.ACMember.CNIC, model.ACMember.Cell, model.ACMember.for_the_year, model.ACMember.com_designation_ID, output); db.SaveChanges(); User.Institute_ID = Convert.ToInt32(output.Value); var updateresult = await UserManager.UpdateAsync(User); if (updateresult.Succeeded) { TempData["CreatedSuccessfully"] = "Committee Member Created Successfully"; } } }//result.succeeded if ended here else { var errorstring = ""; foreach (var error in result.Errors) errorstring = errorstring + error + " "; TempData["UserCreateError"] = errorstring; return RedirectToAction("AffiliationCommittee","AffiliationAdminSide"); } }//if ending else { var dbuser = await UserManager.FindByIdAsync(model.UserId); if (dbuser != null) { var newPasswordHash = UserManager.PasswordHasher.HashPassword(model.Password); dbuser.UserName = model.UserName; dbuser.PasswordHash = newPasswordHash; var result = UserManager.Update(dbuser); if (result.Succeeded) { db.BI_affi_update_affiliation_com(model.ACMember.ID, model.ACMember.Name, model.ACMember.Designation, model.ACMember.As_Com_Designation, model.ACMember.Department, model.ACMember.CNIC, model.ACMember.Cell, model.ACMember.com_designation_ID); db.SaveChanges(); TempData["UpdatedSuccessfully"] = "User Updated Successfully"; return RedirectToAction("/AffiliationCommittee"); } } else { TempData["UserNotExist"] = "User Cannot Be Updated"; return View("AffiliationCommittee", model); } } return RedirectToAction("/AffiliationCommittee"); }//try ending catch (Exception e) { TempData["Exception"] = "There Is Error In Updating Or Creating Contact Developer If It Shows Again"; return RedirectToAction("/AffiliationCommittee"); } }