예제 #1
0
        public IActionResult CreatePost(EditCreateViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(NotFound());
            }

            if (model.Instructor != null)
            {
                _instructorRepository.Add(model.Instructor);

                var instructorId = model.Instructor.InstructorId;

                foreach (var data in model.AssignedCourseData)
                {
                    if (data.Assigned)
                    {
                        _courseAssignmentRepository.Add(new CourseAssignment()
                        {
                            CourseId     = data.CourseId,
                            InstructorId = instructorId
                        });
                    }
                }
                return(RedirectToAction("Index"));
            }
            return(View("Create"));
        }
예제 #2
0
        public ActionResult Store(CourseInstructor request)
        {
            RequiredFields model = new RequiredFields();

            model.Instructor = request;
            object validateFields = _validationService.ValidateRequest("Instructor", model);

            if (JsonConvert.SerializeObject(validateFields).Length > 2)
            {
                return(BadRequest(validateFields));
            }

            try
            {
                var response = _instructorRepository.Add(request);
                if (response == true)
                {
                    return(Ok(new GenericResult {
                        Response = response, Message = "Instructor has been successfully saved."
                    }));
                }
                else
                {
                    return(BadRequest(new GenericResult {
                        Response = response, Message = "Instructor is already assigned in user group."
                    }));
                }
            } catch (Exception e) {
                return(BadRequest(e));
            }
        }
예제 #3
0
        public IActionResult CreatePost(CreateInstructorViewModel model)
        {
            if (ModelState.IsValid)
            {
                _instructorRepository.Add(model.Instructor);

                var instructorId = model.Instructor.InstructorId;

                var courseAssignment = new List <CourseAssignment>();

                if (model.AssignedCourseData != null)
                {
                    foreach (var data in model.AssignedCourseData)
                    {
                        if (data.Assigned)
                        {
                            //courseAssignment.Add(new CourseAssignment(){CourseId = data.CourseId,InstructorId = instructorId});
                            _courseAssignmentRepository.Add(new CourseAssignment()
                            {
                                CourseId = data.CourseId, InstructorId = instructorId
                            });
                        }
                    }
                }

                return(RedirectToAction("Index"));
            }

            return(View("Create"));
        }
예제 #4
0
 public int AddInstructor(Person person)
 {
     using (TransactionScope tran = new TransactionScope()) {
         Persons.Add(person); // this person is tracked and in context
         // then we can add as instructor by setting the navigation property.
         //person.Instructor = new Instructor() {
         //    Id = person.Id
         //};
         Instructors.Add(new Instructor()
         {
             Id = person.Id
         });
         //   Complete();
         tran.Complete();
         return(person.Id);
     }
 }
예제 #5
0
 public void CreateInstructor(Instructor instructor)
 {
     using (var transaction = new TransactionScope())
     {
         _instructorRepository.Add(instructor);
         _instructorRepository.SaveChanges();
         transaction.Complete();
     }
 }
        public ActionResult Create([Bind(Include = "LastName,FirstMidName,HireDate,OfficeAssignment")] Instructor instructor, string[] selectedCourses)
        {
            if (ModelState.IsValid)
            {
                instructorRepository.Add(instructor, selectedCourses?.Select(int.Parse).ToArray() ?? new int[] { });
                return(RedirectToAction("Index"));
            }

            ListAssignableCourses(instructor.Courses);
            return(View(instructor));
        }
예제 #7
0
        public Instructor Add(Instructor instructor)
        {
            if (!instructor.IsValid())
            {
                return(instructor);
            }

            instructor.ValidationResult = new InstructorReadyToRegisterValidation(instructorRepository).Validate(instructor);

            if (!instructor.ValidationResult.IsValid)
            {
                return(instructor);
            }

            return(instructorRepository.Add(instructor));
        }
예제 #8
0
        public async Task <IActionResult> register([FromBody] SaveInstructorResource instructorResource)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            Instructor instructor = mapper.Map <SaveInstructorResource, Instructor>(instructorResource);

            instructorRepository.Add(instructor);
            await unitOfWork.CompleteAsync();

            instructor = await instructorRepository.GetOne(instructor.Id);

            var response = mapper.Map <Instructor, SaveInstructorResource>(instructor);

            return(Ok(response));
        }
예제 #9
0
 public void CreateInstructor(Instructor instructor)
 {
     _instructorRepository.Add(instructor);
 }
예제 #10
0
 public void AddInstructor(Instructor instructor)
 {
     _repository.Add(instructor);
 }
        protected void AddTManual_Click(object sender, EventArgs e)
        {
            Security objSecurity                  = new Security();
            var      vtxtLName                    = txtLName.Text;
            var      vtxtSuffix                   = txtSuffix.Text;
            var      vtxtFName                    = txtFName.Text;
            var      vtxtMName                    = txtMName.Text;
            var      vtxtAddress_1                = txtAddress_1.Text;
            var      vtxtCity_1                   = txtCity_1.Text;
            var      vtxtState_1                  = txtState_1.Text;
            var      vtxtZipCode_1                = txtZipCode_1.Text;
            var      vtxtAddress_2                = txtAddress_2.Text;
            var      vtxtCity_2                   = txtCity_2.Text;
            var      vtxtState_2                  = txtState_2.Text;
            var      vtxtZipcode_2                = txtZipcode_2.Text;
            var      vtxtPhone                    = txtPhone.Text;
            var      vtxtEmailAddress             = txtEmailAddress.Text;
            var      vtxtDOB                      = txtDOB.Text;
            var      vtxtSSNO                     = txtSSNO.Text;
            var      vtxtInstructTP               = txtInstructTP.Text;
            var      vtxtInstructAcctNum          = txtInstructAcctNum.Text;
            var      vtxtInstructContFN           = txtInstructContFN.Text;
            var      vtxtInstructContLN           = txtInstructContLN.Text;
            var      vtxtInstructContPhone        = txtInstructContPhone.Text;
            var      vtxtInstructContAddress      = txtInstructContAddress.Text;
            var      vtxtInstructContCity         = txtInstructContCity.Text;
            var      vtxtInstructContState        = txtInstructContState.Text;
            var      vtxtInstructContZipcode      = txtInstructContZipcode.Text;
            var      vtxtACCID                    = txtACCID.Text;
            DateTime vAccreditationExpirationDate = default(DateTime);

            if (!string.IsNullOrWhiteSpace(txtAccreditationExpirationDate.Text))
            {
                DateTime.TryParse(txtAccreditationExpirationDate.Text, out vAccreditationExpirationDate);
            }
            var      vtxtNewInitTrainingCard = txtNewInitTrainingCard.Text;
            DateTime vtxtNewInitStartDate    = default(DateTime);

            if (!string.IsNullOrWhiteSpace(txtNewInitStartDate.Text))
            {
                DateTime.TryParse(txtNewInitStartDate.Text, out vtxtNewInitStartDate);
            }
            DateTime vtxtNewInitEndDate = default(DateTime);

            if (!string.IsNullOrWhiteSpace(txtNewInitEndDate.Text))
            {
                DateTime.TryParse(txtNewInitEndDate.Text, out vtxtNewInitEndDate);
            }
            var      vtxtRenewalTrainingCard = txtRenewalTrainingCard.Text;
            DateTime vtxtRenewalStartDate    = default(DateTime);

            if (!string.IsNullOrWhiteSpace(txtRenewalStartDate.Text))
            {
                DateTime.TryParse(txtRenewalStartDate.Text, out vtxtRenewalStartDate);
            }
            DateTime vtxtRenewalEndDate = default(DateTime);

            if (!string.IsNullOrWhiteSpace(txtRenewalEndDate.Text))
            {
                DateTime.TryParse(txtRenewalEndDate.Text, out vtxtRenewalEndDate);
            }
            var vupload_1 = string.Empty;
            var vupload_2 = string.Empty;

            try
            {
                vupload_1 = Path.Combine("uf", uploadNewInstructors.FileName);
                uploadNewInstructors.PostedFile.SaveAs(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, vupload_1));
                vupload_2 = Path.Combine("uf", uploadNewInspectorTech.FileName);
                uploadNewInspectorTech.PostedFile.SaveAs(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, vupload_2));
            }
            catch { }
            var vtxtNewRenewAcctNum        = txtNewRenewAcctNum.Text;
            var vtxtNewRenewAcctExpireDate = txtNewRenewAcctExpireDate.Text;
            var vchkIAgree     = chkIAgree.Checked ? 1 : 0;
            var vdropIsRenewal = int.Parse(dropIsRenewal.SelectedItem.Value);
            //var vdropInstructCategory = int.Parse(objcryptoJS.AES_decrypt(dropInstructCategory.SelectedItem.Value, AppConstants.secretKey, AppConstants.initVec).ToString());
            var vdropInstructCategory = int.Parse("2");

            var instructor = Instructor.Create(vtxtLName, vtxtSuffix, vtxtFName, vtxtMName, vtxtAddress_1, vtxtCity_1, vtxtState_1, vtxtZipCode_1, vtxtAddress_2,
                                               vtxtCity_2, vtxtState_2, vtxtZipcode_2, vtxtPhone, vtxtEmailAddress, vtxtDOB, vtxtSSNO, vtxtInstructTP, vtxtInstructAcctNum, vtxtInstructContFN,
                                               vtxtInstructContLN, vtxtInstructContPhone, vtxtInstructContAddress, vtxtInstructContCity, vtxtInstructContState, vtxtInstructContZipcode, vdropIsRenewal,
                                               vtxtACCID, vAccreditationExpirationDate, vdropInstructCategory, vtxtNewInitTrainingCard, vtxtNewInitStartDate, vtxtNewInitEndDate, vtxtRenewalTrainingCard,
                                               vtxtRenewalStartDate, vtxtRenewalEndDate, vupload_1, vtxtNewRenewAcctNum, vtxtNewRenewAcctExpireDate, vupload_2, vchkIAgree);

            _instructorRepository.Add(instructor);
            _uow.Commit();

            string strBackToForms = objcryptoJS.AES_encrypt("10", AppConstants.secretKey, AppConstants.initVec).ToString();

            ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "script", "CallNotify('Your Application has been submitted successfully!', '', 'success', 'RoleDesc.aspx?Dash=active&cgi=" + System.Web.HttpUtility.UrlEncode(strBackToForms) + "');", true);
        }
예제 #12
0
 public void CreateInstructor(Instructor instructor)
 {
     _instructorRepository.Add(instructor);
     _instructorRepository.SaveChanges();
 }