Exemplo n.º 1
0
        public ActionResult Create(TrainerViewModel trainerViewModel)
        {
            var organisationId = UserOrganisationId;

            if (ModelState.IsValid)
            {
                trainerViewModel.Trainer.OrganisationId = UserOrganisationId;
                trainerViewModel.Trainer.CentreId       = UserCentreId;
                trainerViewModel.Trainer.EmailId        = trainerViewModel.Trainer.EmailId.ToLower();
                trainerViewModel.Trainer = NidanBusinessService.CreatetTrainer(UserOrganisationId, trainerViewModel.Trainer);
                var personnel = new Personnel()
                {
                    OrganisationId = organisationId,
                    DOB            = trainerViewModel.Trainer.DateOfBirth,
                    Title          = trainerViewModel.Trainer.Title,
                    Forenames      = trainerViewModel.Trainer.FirstName,
                    Surname        = trainerViewModel.Trainer.LastName,
                    Email          = trainerViewModel.Trainer.EmailId,
                    Address1       = trainerViewModel.Trainer.Address1,
                    Address2       = trainerViewModel.Trainer.Address2,
                    Address3       = trainerViewModel.Trainer.Address3,
                    Address4       = trainerViewModel.Trainer.Address4,
                    Postcode       = trainerViewModel.Trainer.PinCode.ToString(),
                    Mobile         = trainerViewModel.Trainer.Mobile.ToString(),
                    Telephone      = "12345678",
                    NINumber       = "NZ1234567",
                    CentreId       = trainerViewModel.Trainer.CentreId
                };
                NidanBusinessService.CreatePersonnel(organisationId, personnel);
                trainerViewModel.Trainer.PersonnelId = personnel.PersonnelId;
                NidanBusinessService.UpdateTrainer(organisationId, trainerViewModel.Trainer);
                CreateTrainerUserAndRole(personnel);
                return(RedirectToAction("Edit", new { id = trainerViewModel.Trainer.TrainerId }));
            }
            //trainerViewModel.Courses = new SelectList(NidanBusinessService.RetrieveCourses(organisationId, e => true).ToList());
            trainerViewModel.Sectors   = new SelectList(NidanBusinessService.RetrieveSectors(organisationId, e => true).ToList());
            trainerViewModel.Talukas   = new SelectList(NidanBusinessService.RetrieveTalukas(organisationId, e => true).ToList());
            trainerViewModel.Districts = new SelectList(NidanBusinessService.RetrieveDistricts(organisationId, e => true).ToList());
            trainerViewModel.States    = new SelectList(NidanBusinessService.RetrieveStates(organisationId, e => true).ToList());
            return(View(trainerViewModel));
        }