public async Task <List <TrainerVM> > GetTrainer(string id)
        {
            var getId = await _context.Trainings
                        .Include(x => x.Employee)
                        .Where(x => x.Employee.EmpId == id)
                        .ToListAsync();

            if (getId.Count == 0)
            {
                return(null);
            }
            List <TrainerVM> list = new List <TrainerVM>();

            foreach (var item in getId)
            {
                var trainer = new TrainerVM()
                {
                    EmpId         = item.Employee.EmpId,
                    EmployeeName  = item.Employee.Name,
                    TrainingId    = item.Id,
                    TrainingTitle = item.Title,
                };
                list.Add(trainer);
            }
            return(list);
        }
        public async Task <List <TrainerVM> > GetTrainerQuestion(string id)
        {
            var getQues = await _context.Questions.Include("Training").Include(x => x.Training.Employee).Where(x => x.isDelete == false && x.Training.Employee.EmpId == id).ToListAsync();

            if (getQues.Count == 0)
            {
                return(null);
            }
            List <TrainerVM> list = new List <TrainerVM>();

            foreach (var item in getQues)
            {
                var trainer = new TrainerVM()
                {
                    EmpId         = item.Training.Employee.EmpId,
                    EmployeeName  = item.Training.Employee.Name,
                    TrainingId    = item.Training.Id,
                    TrainingTitle = item.Training.Title,
                    QuestionId    = item.Id,
                    QuestionDesc  = item.QuestionDesc,
                };
                list.Add(trainer);
            }
            return(list);
        }
Ejemplo n.º 3
0
        public ActionResult AddTrainer(TrainerVM t)
        {
            ITrainerRepo trepo = TrainerRepoFactory.Create();
            IClientRepo  repo  = ClientRepoFactory.Create();

            if (ModelState.IsValid)
            {
                var trainer = new Trainer
                {
                    StartDate   = DateTime.Today,
                    TrainerID   = t.TrainerID,
                    TrainerName = t.TrainerName,
                    HourlyRate  = t.HourlyRate
                };
                foreach (var clientID in t.SelectedClientID)
                {
                    trainer.Clientelle.Add(repo.GetClientById(clientID));
                }
                trepo.AddTrainer(trainer);
            }
            else
            {
                return(View(t));
            }
            return(RedirectToAction("Index", "Home"));
        }
Ejemplo n.º 4
0
 public ActionResult Edit(int?id)
 {
     if (id != null)
     {
         Trainers tr = db.Trainers.FirstOrDefault(t => t.id == id);
         if (tr != null)
         {
             TrainerVM model = new TrainerVM()
             {
                 Trainer  = tr,
                 Trainers = db.Trainers.ToList(),
                 Header   = "Edit Trainer",
                 Action   = "Edit"
             };
             return(View("Index", model));
         }
         else
         {
             return(HttpNotFound());
         }
     }
     else
     {
         return(RedirectToAction("Index"));
     }
 }
Ejemplo n.º 5
0
        public ActionResult Update(TrainerVM data)
        {
            Trainer std = trnRepo.GetById(data.ID);

            std.FirstName = data.FirstName;
            std.LastName  = data.LastName;
            std.EMail     = data.Email;
            trnRepo.Edit(std);
            return(RedirectToAction("TrainerList", "AdminTrainer"));
        }
Ejemplo n.º 6
0
        // GET: Trainer
        public ActionResult Index()
        {
            TrainerVM model = new TrainerVM()
            {
                Trainer  = new Trainers(),
                Trainers = db.Trainers.ToList(),
                Header   = "Add Trainer",
                Action   = "Create"
            };

            return(View(model));
        }
Ejemplo n.º 7
0
        public ActionResult Update(int id)
        {
            Trainer   trn   = trnRepo.GetById(id);
            TrainerVM model = new TrainerVM {
                ID        = trn.Id,
                FirstName = trn.FirstName,
                LastName  = trn.LastName,
                Email     = trn.EMail
            };

            return(View(model));
        }
Ejemplo n.º 8
0
        public ActionResult EditTrainer(int id)
        {
            ITrainerRepo trepo   = TrainerRepoFactory.Create();
            IClientRepo  repo    = ClientRepoFactory.Create();
            var          trainer = trepo.GetTrainerById(id);
            var          model   = new TrainerVM
            {
                TrainerID   = trainer.TrainerID,
                TrainerName = trainer.TrainerName,
                HourlyRate  = trainer.HourlyRate,
            };

            return(View(model));
        }
Ejemplo n.º 9
0
        public ActionResult Add(TrainerVM data)
        {
            Trainer trn = new Trainer();

            trn.FirstName   = data.FirstName;
            trn.LastName    = data.LastName;
            trn.EMail       = data.Email;
            trn.IsActive    = true;
            trn.Username    = data.FirstName.Substring(0, 2).ToLower() + "." + data.LastName.ToLower();
            trn.Password    = data.FirstName.Substring(0, 2).ToLower() + "." + data.LastName.ToLower() + "123";
            trn.FullName    = data.FirstName + " " + data.LastName;
            trn.CreatedDate = DateTime.UtcNow;

            trnRepo.Add(trn);
            return(RedirectToAction("TrainerList", "AdminTrainer"));
        }
Ejemplo n.º 10
0
        public ActionResult SaveTrainer(TrainerVM TrainerInfo)
        {
            if (TrainerInfo.TrainerInformation.TrianerId == -1)
            {
                TrainerInformation ti = new TrainerInformation();

                ti.TrainerName = TrainerInfo.TrainerInformation.TrainerName;
                ti.Address     = TrainerInfo.TrainerInformation.Address;
                ti.Contact     = TrainerInfo.TrainerInformation.Contact;
                ti.Country     = TrainerInfo.TrainerInformation.Country;
                if (TrainerInfo.TrainerInformation.Profile.ContentLength > 0)
                {
                    ti.Profile = TrainerInfo.TrainerInformation.Profile.FileName;
                    string fileName = Path.GetFileName(TrainerInfo.TrainerInformation.Profile.FileName);
                    string path     = Path.Combine(Server.MapPath("~/FileUploads"), ti.Profile);
                    TrainerInfo.TrainerInformation.Profile.SaveAs(path);
                }
                ti.Remarks     = TrainerInfo.TrainerInformation.Remarks;
                ti.Technology  = TrainerInfo.TrainerInformation.Technology;
                ti.TrainerRate = TrainerInfo.TrainerInformation.TrainerRate;
                ti.VendorName  = TrainerInfo.TrainerInformation.VendorName;
                ti.IsActive    = true;
                dbContext.TrainerInformations.Add(ti);
                dbContext.SaveChanges();
            }

            else
            {
                TrainerInformation trainerInfoDetail = dbContext.TrainerInformations.
                                                       Where(x => x.TrianerId == TrainerInfo.TrainerInformation.TrianerId).FirstOrDefault();
                if (trainerInfoDetail != null)
                {
                    trainerInfoDetail.TrainerName = TrainerInfo.TrainerInformation.TrainerName;
                    trainerInfoDetail.Address     = TrainerInfo.TrainerInformation.Address;
                    trainerInfoDetail.Contact     = TrainerInfo.TrainerInformation.Contact;
                    trainerInfoDetail.Country     = TrainerInfo.TrainerInformation.Country;
                    trainerInfoDetail.Profile     = TrainerInfo.TrainerInformation.Profile.FileName;
                    trainerInfoDetail.Remarks     = TrainerInfo.TrainerInformation.Remarks;
                    trainerInfoDetail.Technology  = TrainerInfo.TrainerInformation.Technology;
                    trainerInfoDetail.TrainerRate = TrainerInfo.TrainerInformation.TrainerRate;
                    trainerInfoDetail.VendorName  = TrainerInfo.TrainerInformation.VendorName;
                }
                dbContext.SaveChanges();
            }
            return(RedirectToAction("TrainersList"));
        }
Ejemplo n.º 11
0
        public MainVM(IWordStorage wordStorage, IStorage<WordResult> wordResultStorage, TrainerVM trainerVM, Language language, Language nativeLanguage)
        {
            this.WordStorage = wordStorage;
            this.WordResultStorage = wordResultStorage;

            this.Language = language;
            this.NativeLanguage = nativeLanguage;

            this.TrainerVM = trainerVM;

            this.Exit = new Command((o) =>
            {
                if (this.OnExitApp != null)
                    this.OnExitApp(this, EventArgs.Empty);
            });

            this.OpenEditorCmd = new Command(this.OpenEditor);
        }
Ejemplo n.º 12
0
 public ActionResult Edit(int id, Trainers Trainer)
 {
     if (ModelState.IsValid)
     {
         db.Entry(Trainer).State = System.Data.Entity.EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     else
     {
         TrainerVM model = new TrainerVM()
         {
             Trainer  = new Trainers(),
             Trainers = db.Trainers.ToList(),
             Header   = "Add Trainer",
             Action   = "Create"
         };
         return(View("Index", model));
     }
 }
Ejemplo n.º 13
0
 // GET: Trainer/Create
 public ActionResult Create(Trainers Trainer)
 {
     if (ModelState.IsValid)
     {
         db.Trainers.Add(Trainer);
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     else
     {
         TrainerVM model = new TrainerVM()
         {
             Trainer  = new Trainers(),
             Trainers = db.Trainers.ToList(),
             Header   = "Add Trainer",
             Action   = "Create"
         };
         return(View("Index", model));
     }
 }
Ejemplo n.º 14
0
        // GET: Trainer
        public ActionResult Index(int Id = -1)
        {
            TrainerInformation TrainerInfo = dbContext.TrainerInformations.
                                             Where(x => x.TrianerId == Id && x.IsActive == true).FirstOrDefault();

            if (TrainerInfo == null)
            {
                var trainerVM = new TrainerVM()
                {
                    countryList = new CountryBO().GetList().AsEnumerable()
                };
                trainerVM.TrainerInformation = new TrainerInformationVM()
                {
                    TrianerId = Id
                };
                return(View(trainerVM));
            }
            else
            {
                var trainerVM = new TrainerVM()
                {
                    countryList = new CountryBO().GetList().AsEnumerable()
                };
                trainerVM.TrainerInformation = new TrainerInformationVM()
                {
                    TrainerName = TrainerInfo.TrainerName,
                    Address     = TrainerInfo.Address,
                    Contact     = TrainerInfo.Contact,
                    Country     = TrainerInfo.Country,
                    TrianerId   = TrainerInfo.TrianerId,
                    // Profile = "~/FileUploads/" + TrainerInfo.Profile,
                    Remarks     = TrainerInfo.Remarks,
                    Technology  = TrainerInfo.Technology,
                    TrainerRate = TrainerInfo.TrainerRate,
                    VendorName  = TrainerInfo.VendorName,
                };

                return(View(trainerVM));
            }
        }
Ejemplo n.º 15
0
        public ActionResult EditTrainer(TrainerVM t)
        {
            IClientRepo  repo  = ClientRepoFactory.Create();
            ITrainerRepo trepo = TrainerRepoFactory.Create();

            if (ModelState.IsValid)
            {
                var trainer = new Trainer
                {
                    Clientelle  = new List <Client>(),
                    TrainerID   = t.TrainerID,
                    TrainerName = t.TrainerName,
                    HourlyRate  = t.HourlyRate,
                    StartDate   = t.StartDate,
                };
                foreach (var clientID in t.SelectedClientID)
                {
                    trainer.Clientelle.Add(repo.GetClientById(clientID));
                }
                trepo.EditTrainer(trainer);
            }
            return(RedirectToAction("Index", "Home"));
        }