Exemple #1
0
        public JsonResult Create(AddGuarantorViewModel model)
        {
            if (ModelState.IsValid)
            {
                Guarantor guarantor = new Guarantor();
                guarantor.Name      = model.Name;
                guarantor.StudentId = model.StudentId;
                guarantor.Phone     = model.Phone;
                guarantor.DocUrl    = model.DocUrl;
                var newGuarantor = _employeeRepository.AddGuarantor(guarantor);

                StudentGuarantor studentGuarantor = new StudentGuarantor
                {
                    GuarantorId = newGuarantor.ID,
                    StudentId   = model.StudentId
                };
                var savedSG = _db.StudentGuarantor.Add(studentGuarantor);
                _db.SaveChanges();

                if (newGuarantor == null)
                {
                    return(Json(new { success = false, message = "Error while deletiing" }));
                }
                else
                {
                    return(Json(new { success = true, message = "Object saved", type = "guarantor", id = newGuarantor.StudentId }));
                }
            }
            return(Json(new { success = false, message = "Invalid Submission" }));
        }
 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));
 }
Exemple #3
0
        public StudentGuarantor UpdateStdGtr(StudentGuarantor _studentGuarantor)
        {
            var model = dbContext.StudentGuarantors.Attach(_studentGuarantor);

            model.State = Microsoft.EntityFrameworkCore.EntityState.Modified;
            dbContext.SaveChanges();
            return(_studentGuarantor);
        }
Exemple #4
0
        public StudentGuarantor RemoveStsGtr(Guid Id)
        {
            StudentGuarantor studentGuarantor = dbContext.StudentGuarantors.Find(Id);

            if (studentGuarantor != null)
            {
                dbContext.StudentGuarantors.Remove(studentGuarantor);
                dbContext.SaveChanges();
            }
            return(studentGuarantor);
        }
Exemple #5
0
        public IActionResult AddGuarantor(AddGuarantorViewModel model)
        {
            if (ModelState.IsValid)
            {
                Guarantor guarantor = new Guarantor();
                guarantor.Name      = model.Name;
                guarantor.StudentId = model.StudentId;
                guarantor.Phone     = model.Phone;
                guarantor.DocUrl    = model.DocUrl;
                var newGuarantor = _employeeRepository.AddGuarantor(guarantor);

                StudentGuarantor studentGuarantor = new StudentGuarantor
                {
                    GuarantorId = newGuarantor.ID,
                    StudentId   = model.StudentId
                };
                _db.StudentGuarantor.Add(studentGuarantor);
                _db.SaveChanges();

                return(RedirectToAction("Index", "Guarantor"));
            }
            return(View(model));
        }
Exemple #6
0
 public StudentGuarantor AddStdGtr(StudentGuarantor _studentGuarantor)
 {
     dbContext.StudentGuarantors.Add(_studentGuarantor);
     dbContext.SaveChanges();
     return(_studentGuarantor);
 }