private void GetDataBasedOnUserType(vmDashBoard objDashboard, System.Collections.Generic.IList <BatchModel> batch, UserType CurrentUserType, string CurrentUserEmail) { if (CurrentUserType == UserType.Trainer) { objDashboard.BatchList = batch; var LastBatchID = batch.LastOrDefault().Id; var IndList = _Inductee.Get(20, 0); objDashboard.InducteeList = IndList.Where(i => i.BatchID == LastBatchID).OrderByDescending(i => i.Batch.BatchDates.OrderBy(f => f.BatchDate).First()).ToList(); } else if (CurrentUserType == UserType.Trainee) { var inducteeBatchId = _Inductee.Get(CurrentUserEmail).BatchID; var traineesBatch = batch.Where(B => B.Id == inducteeBatchId).Select(B => B).ToList <BatchModel>(); if (traineesBatch.Any()) { objDashboard.BatchList = traineesBatch; var IndList = _Inductee.Get(20, 0); objDashboard.InducteeList = IndList.Where(i => i.BatchID == inducteeBatchId).OrderByDescending(i => i.Id).ToList(); } } }
public BatchModel GetBatchDetailsByTraineeId(string traineeId) { int traineeIntId = Convert.ToInt32(traineeId); var user = db.Tranner.FirstOrDefault(us => us.Id == traineeIntId); var inducteeBatchId = _Inductee.Get(user.Email).BatchID; var traineesBatch = db.Batch.Where(B => B.Id == inducteeBatchId).Select(B => B).FirstOrDefault(); var batchDetails = (from inductee in db.Inductee join trainee in db.Tranner on inductee.Email equals trainee.Email join batch in db.Batch on inductee.BatchID equals batch.Id select batch).FirstOrDefault(); batchDetails.trainer = traineesBatch.trainer; return(batchDetails); }
public CustomTrainerFeedbackModel GetTrainerFeedbackListForTrainer(int batchId, string traineeId) { var customTrainerFeedback = new CustomTrainerFeedbackModel(); var feedbackList = db.TrainersFeedback.Where(f => f.BatchID == batchId && f.TraineeID.ToString() == traineeId).OrderByDescending(d => d.DateCreated).ToList(); int traineeIntId = Convert.ToInt32(traineeId); var user = db.Tranner.FirstOrDefault(us => us.Id == traineeIntId); var inducteeBatchId = _Inductee.Get(user.Email).BatchID; var traineesBatch = db.Batch.Where(B => B.Id == inducteeBatchId).Select(B => B).FirstOrDefault(); customTrainerFeedback.BatchID = traineesBatch.Id; customTrainerFeedback.BatchName = traineesBatch.Name; customTrainerFeedback.BatchStartDate = traineesBatch.BatchDates.OrderBy(p => p.BatchDate).Select(p => p.BatchDate).FirstOrDefault(); customTrainerFeedback.BatchEndDate = traineesBatch.BatchDates.OrderBy(p => p.BatchDate).Select(p => p.BatchDate).LastOrDefault(); customTrainerFeedback.TrainerID = traineesBatch.trainer.Id; customTrainerFeedback.TrainerName = traineesBatch.trainer.Name; customTrainerFeedback.TrainerEmail = traineesBatch.trainer.Email; var feedbackReponseList = new List <FeedbackResponse>(); if (feedbackList.Any()) //if records exist { foreach (var feedback in feedbackList) { var feedbackReponse = new FeedbackResponse(); feedbackReponse.ID = feedback.ID; feedbackReponse.Rating = feedback.Rating; feedbackReponse.WhatWentWell = feedback.WhatWentWell; feedbackReponse.DidnotGoWell = feedback.DidnotGoWell; feedbackReponse.CanBeImproved = feedback.CanBeImproved; feedbackReponse.TraineeID = feedback.TraineeID; feedbackReponse.TraineeName = db.Tranner.Find(feedback.TraineeID).Name; feedbackReponseList.Add(feedbackReponse); } } customTrainerFeedback.FeedbackReponse = feedbackReponseList; return(customTrainerFeedback); }
// GET: /Inductee/ public ActionResult Index() { var Inductees = InducteeRepo.Get(); return(View(Inductees)); }