public async Task <IActionResult> Edit(int id, [Bind("Id,StateCorporationId,personBeingEvaluatedId,DateOfAppointment,EnablingLegalInstument,ChairpersonId,CEOId,DirectorId,EndofTerm,EvaluationTypeId")] EvaluationSubject evaluationSubject) { if (id != evaluationSubject.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(evaluationSubject); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!EvaluationSubjectExists(evaluationSubject.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } // ViewData["CEOId"] = new SelectList(_context.CEO, "Id", "Id", evaluationSubject.CEOId); // ViewData["ChairpersonId"] = new SelectList(_context.Chairperson, "Id", "Id", evaluationSubject.ChairpersonId); // ViewData["DirectorId"] = new SelectList(_context.Director, "Id", "Id", evaluationSubject.DirectorId); ViewData["EvaluationTypeId"] = new SelectList(_context.Set <EvaluationType>(), "Id", "Id", evaluationSubject.EvaluationTypeId); ViewData["StateCorporationId"] = new SelectList(_context.StateCorporation, "Id", "Id", evaluationSubject.StateCorporationId); ViewData["personBeingEvaluatedId"] = new SelectList(_context.Set <ApplicationUser>(), "Id", "Id", evaluationSubject.personBeingEvaluatedId); return(View(evaluationSubject)); }
public async Task <EvaluationSubject> DeleteSubjectAsync(EvaluationSubject subject, CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); ThrowIfDisposed(); if (subject == null) { throw new ArgumentNullException(nameof(subject)); } Context.EvaluationSubjects.Remove(subject); await SaveChanges(cancellationToken); return(subject); }
public async Task <IActionResult> Create([Bind("Id,StateCorporationId,personBeingEvaluatedId,DateOfAppointment,EnablingLegalInstument,ChairpersonId,CEOId,DirectorId,EndofTerm,EvaluationTypeId")] EvaluationSubject evaluationSubject) { if (ModelState.IsValid) { _context.Add(evaluationSubject); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } // ViewData["CEOId"] = new SelectList(_context.CEO, "Id", "Id", evaluationSubject.CEOId); // ViewData["ChairpersonId"] = new SelectList(_context.Chairperson, "Id", "Id", evaluationSubject.ChairpersonId); // ViewData["DirectorId"] = new SelectList(_context.Director, "Id", "Id", evaluationSubject.DirectorId); ViewData["EvaluationTypeId"] = new SelectList(_context.Set <EvaluationType>(), "Id", "Id", evaluationSubject.EvaluationTypeId); ViewData["StateCorporationId"] = new SelectList(_context.StateCorporation, "Id", "Id", evaluationSubject.StateCorporationId); ViewData["personBeingEvaluatedId"] = new SelectList(_context.Set <ApplicationUser>(), "Id", "Id", evaluationSubject.personBeingEvaluatedId); return(View(evaluationSubject)); }
public async Task <IActionResult> Create(Questionnaire cEO, string[] quizresponse, int CategoryId, int corporationId, string LegalInstrument, string type, string ChairmanId, DateTime?DateofAppointment, string Endofterm, string DirectorId, string CEOId) { if (quizresponse.Length > 0) { IQueryable <EvaluationSubject> subject = _context.EvaluationSubject; var personBeingEvaluatedId = _usermanager.GetUserId(User); if (type == "Individual") { subject = subject.Where(x => x.EvaluationTypeId == CategoryId && x.StateCorporationId == corporationId && x.personBeingEvaluatedId == _usermanager.GetUserId(User)); } if (type == "Chairperson") { if (_usermanager.GetUserId(User) == ChairmanId) { TempData["errorMessage"] = $"You are a Chairperson, you are not allowed to evalaute yourself!!!, THIS WON'T COUNT"; return(RedirectToAction("Index", "Home")); } personBeingEvaluatedId = null; personBeingEvaluatedId = null; subject = subject.Where(x => x.EvaluationTypeId == CategoryId && x.StateCorporationId == corporationId && x.ChairpersonId == ChairmanId); } if (type == "Ceos") { if (_usermanager.GetUserId(User) == CEOId) { TempData["errorMessage"] = $"You are a C.E.O, you are not allowed to evalaute yourself!!!, THIS WON'T COUNT"; return(RedirectToAction("Index", "Home")); } personBeingEvaluatedId = null; subject = subject.Where(x => x.EvaluationTypeId == CategoryId && x.StateCorporationId == corporationId && x.CEOId == CEOId); } if (type == "Director") { personBeingEvaluatedId = null; subject = subject.Where(x => x.EvaluationTypeId == CategoryId && x.StateCorporationId == corporationId && x.DirectorId == DirectorId); } int EvaluationSubjectId = 0; if (subject.Any()) { EvaluationSubjectId = subject.Take(1).SingleOrDefault().Id; } else { EvaluationSubject newSubject = new EvaluationSubject() { EvaluationTypeId = CategoryId, EnablingLegalInstument = LegalInstrument, StateCorporationId = corporationId, CEOId = CEOId, ChairpersonId = ChairmanId, DirectorId = DirectorId, DateOfAppointment = DateofAppointment, EndofTerm = Endofterm, personBeingEvaluatedId = personBeingEvaluatedId }; _context.Add(newSubject); _context.SaveChanges(); EvaluationSubjectId = newSubject.Id; } var responseforSubject = _context.Response.Where(x => x.EvaluationSubjectId == EvaluationSubjectId && x.RespondantId == _usermanager.GetUserId(User)); //checked if user has taken questionaier for the subjectcandidate if (responseforSubject.Any()) { TempData["flashMessage"] = $"Evaluation Had Already been Taken !! Submition Not Saved , THIS WON'T COUNT"; return(RedirectToAction("Index", "Home")); } foreach (var quizeAndResponse in quizresponse) { string[] ids = quizeAndResponse.Split(new char[] { '|' }); int response = (int.Parse(ids[0])); int quizId = int.Parse(ids[1]); Response newResponse = new Response() { QuestionId = quizId, Responses = (Respond)response, RespondantId = _usermanager.GetUserId(User), EvaluationSubjectId = EvaluationSubjectId }; _context.Add(newResponse); } await _context.SaveChangesAsync(); TempData["errorMessage"] = $"Evaluation Taken successfully"; return(RedirectToAction("Index", "Home")); } return(View(cEO)); }