public IActionResult AddGuarantor(GuarantorViewModel guarantorModel)
 {
     if (ModelState.IsValid)
     {
         Guarantor newGuarantor = new Guarantor
         {
             Name         = guarantorModel.Name,
             Address      = guarantorModel.Address,
             Number       = guarantorModel.Number,
             Gender       = guarantorModel.Gender,
             Relationship = guarantorModel.Relationship,
             Occupation   = guarantorModel.Occupation,
             Email        = guarantorModel.Email,
             Nationality  = guarantorModel.Nationality
         };
         var model = _guarantorRepository.AddGuarantor(newGuarantor);
         StudentGuarantor studentGuarantor = new StudentGuarantor
         {
             StudentId   = guarantorModel.StudentId,
             GuarantorId = model.Id
         };
         _studentGuarantor.AddStdGtr(studentGuarantor);
         return(RedirectToAction("studentinfo", "home", new { id = guarantorModel.StudentId }));
     }
     return(View(guarantorModel));
 }
Beispiel #2
0
 public IActionResult create(GuarantorView model)
 {
     if (ModelState.IsValid)
     {
         Guarantor guarantor1 = new Guarantor()
         {
             //ID = model.Id,
             FirstName     = model.FirstName,
             LastName      = model.LastName,
             Address       = model.Address,
             Email         = model.Email,
             Gender        = model.Gender,
             Phone         = model.Phone,
             _student_id   = model.studentID,
             MaritalStatus = model.MaritalStatus,
             Nationality   = model.Nationality
         };
         _guarantor.AddGuarantor(guarantor1);
         return(RedirectToAction("create"));
     }
     return(View());
 }