public int Add(StudentProfileViewModel model, List <AcademicRecordsViewModel> records, GuardianViewModel gardian, InitialPaymentDetailViewModel officeFrom, int[] OriginalDocumentId) { return(_iStudent.Add(model, records, gardian, officeFrom, OriginalDocumentId)); }
// GET: Guardians/Create public ActionResult Create(string rollNo) { GuardianViewModel guardian = new GuardianViewModel(); guardian.rollNo = rollNo; return(View(guardian)); }
// GET: Guardians/Edit/5 public async Task <ActionResult> Edit(string id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Guardian guardian = await Db.Guardians.FindAsync(id); if (guardian == null) { return(HttpNotFound()); } ViewBag.StudentId = new SelectList(await _query.StudentListAsync(userSchool), "StudentId", "FullName", guardian.StudentId); var model = new GuardianViewModel() { GuardianId = guardian.GuardianId, StudentId = guardian.StudentId, FirstName = guardian.FirstName, MiddleName = guardian.MiddleName, LastName = guardian.LastName, Email = guardian.Email, PhoneNumber = guardian.PhoneNumber, Address = guardian.Address, Occupation = guardian.Occupation, LGAOforigin = guardian.LGAOforigin, MotherName = guardian.MotherName, MotherMaidenName = guardian.MotherMaidenName, }; return(View(model)); }
public async Task <ActionResult> Edit([Bind(Include = "GuardianId,Salutation,FirstName,MiddleName,LastName,Gender,PhoneNumber,Email,Address,Occupation,Relationship,Religion,LGAOforigin,StateOfOrigin,MotherName,MotherMaidenName,UserName,FullName,StudentId")] GuardianViewModel model) { if (ModelState.IsValid) { var guardian = await Db.Guardians.FindAsync(model.GuardianId); if (guardian != null) { guardian.StudentId = model.StudentId; guardian.Salutation = model.Salutation.ToString(); guardian.FirstName = model.FirstName; guardian.MiddleName = model.MiddleName; guardian.LastName = model.LastName; guardian.Gender = model.Gender.ToString(); guardian.Email = model.Email; guardian.PhoneNumber = model.PhoneNumber; guardian.Address = model.Address; guardian.Relationship = model.Relationship.ToString(); guardian.Occupation = model.Occupation; guardian.Religion = model.Religion.ToString(); guardian.LGAOforigin = model.LGAOforigin; guardian.StateOfOrigin = model.StateOfOrigin.ToString(); guardian.MotherName = model.MotherName; guardian.MotherMaidenName = model.MotherMaidenName; guardian.SchoolId = userSchool; } Db.Entry(guardian).State = EntityState.Modified; await Db.SaveChangesAsync(); return(RedirectToAction("Index")); } ViewBag.StudentId = new SelectList(await _query.StudentListAsync(userSchool), "StudentId", "FullName", model.StudentId); return(View(model)); }
public async Task <IActionResult> AddGuardian([FromBody] GuardianViewModel guardian) { try { if (ModelState.IsValid) { var newGuardian = this.mapper.Map <GuardianViewModel, Guardian>(guardian); var existingAddress = await _ctx.Addresses.FirstOrDefaultAsync(x => x.address1 == newGuardian.address.address1); if (existingAddress == null) { _ctx.Addresses.Add(guardian.GuardianAddress); } else { newGuardian.address = existingAddress; } var child = _ctx.Mentees.FirstOrDefault(x => x.id == newGuardian.children.ElementAtOrDefault(0).id); newGuardian.children.Clear(); newGuardian.children.Add(child); newGuardian.created_on = DateTime.Now; newGuardian.modified_on = DateTime.Now; _ctx.Guardians.Add(newGuardian); await _ctx.SaveChangesAsync(); return(Created($"/api/guardians/{newGuardian.id}", this.mapper.Map <Guardian, GuardianViewModel>(newGuardian))); } else { return(this.BadRequest(ModelState)); } } catch (Exception e) { Console.WriteLine(e); throw; } }
public async Task <ActionResult> Create(GuardianViewModel model) { if (ModelState.IsValid) { if (Request.IsAuthenticated && !User.IsInRole("SuperAdmin")) { var guardian = new Guardian() { StudentId = model.StudentId, Salutation = model.Salutation.ToString(), FirstName = model.FirstName, MiddleName = model.MiddleName, LastName = model.LastName, Gender = model.Gender.ToString(), Email = model.Email, PhoneNumber = model.PhoneNumber, Address = model.Address, Relationship = model.Relationship.ToString(), Occupation = model.Occupation, Religion = model.Religion.ToString(), LGAOforigin = model.LGAOforigin, StateOfOrigin = model.StateOfOrigin.ToString(), MotherName = model.MotherName, MotherMaidenName = model.MotherMaidenName, SchoolId = userSchool }; Db.Guardians.Add(guardian); await Db.SaveChangesAsync(); return(RedirectToAction("Index")); } ViewBag.Message = "Super Admin Cannot Create a Guardian"; ViewBag.StudentId = new SelectList(Db.Students, "StudentId", "FullName", model.StudentId); return(View(model)); } ViewBag.StudentId = new SelectList(await _query.StudentListAsync(userSchool), "StudentId", "FullName", model.StudentId); return(View(model)); }
public int Add(StudentProfileViewModel model, List <AcademicRecordsViewModel> records, GuardianViewModel gardian, InitialPaymentDetailViewModel officeFrom, int[] OriginalDocumentId) { Student std = new Student(); std.Id = Guid.NewGuid(); std.StdNameBangla = model.StdNameBangla; std.StdNameEnglish = model.StdNameEnglish; std.StdFatherNameBangla = model.StdFatherNameBangla; std.StdFatherNameEnglish = model.StdFatherNameEnglish; std.StdMotherNameBangla = model.StdMotherNameBangla; std.StdMotherNameEnglish = model.StdMotherNameEnglish; std.AdmissionDate = DateTime.Now; std.DateOfBirth = model.DateOfBirth; std.EntryDate = DateTime.Now; std.FormNo = _context.Students.Select(s => s.FormNo).Max() + 1; std.Gender = model.Gender; std.IsActive = true; std.IsSuspended = model.IsSuspended; std.Nationality = model.Nationality; std.PermanentAddress = model.PermanentAddress; std.Phone = model.Phone; std.Email = model.Email; std.Picture = model.Picture; std.PresentAddress = model.PresentAddress; std.Religion = model.Religion; std.SuspendedDesc = model.SuspendedDesc; std.RegistrationNo = officeFrom.RegistrationNo; std.ExamRollNo = officeFrom.ExamRollNo; std.CourseId = model.CourseId; std.AcademicSessionId = model.AcademicSessionId; std.SemesterId = model.SemesterId; _context.Students.Add(std); foreach (var item in records) { if (item.ExamId > 0) { AcademicRecord r = new AcademicRecord(); r.ExamId = item.ExamId; r.GroupId = item.GroupId; r.BoardId = item.BoardId; r.YearOfPassing = item.YearOfPassing; r.RollOfExam = item.RollOfExam; r.Grade = item.Grade; r.StudentId = std.Id; _context.AcademicRecords.Add(r); } } Guardian gar = new Guardian(); gar.Id = Guid.NewGuid(); gar.Name = gardian.Name; gar.Occupation = gardian.Occupation; gar.Relation = gardian.Relation; gar.Phone = gardian.Phone; gar.Address = gardian.Address; gar.StudentId = std.Id; _context.Guardians.Add(gar); InitialPaymentDetail ip = new InitialPaymentDetail(); ip.CourseFee = officeFrom.CourseFee; //ip.InitialPayment = officeFrom.InitialPayment; ip.CourseId = model.CourseId; //ip.PaymentScheduleId = officeFrom.PaymentScheduleId; ip.StudentId = std.Id; _context.InitialPaymentDetails.Add(ip); foreach (var d in OriginalDocumentId) { StudentOriginalDocument stdDOc = new StudentOriginalDocument(); stdDOc.StudentId = std.Id; stdDOc.OriginalDocumentId = d; _context.StudentOriginalDocuments.Add(stdDOc); } StudentSemesterMapping sm = new StudentSemesterMapping(); sm.StudentId = std.Id; sm.SemesterId = model.SemesterId; sm.IsActive = true; _context.StudentSemesterMappings.Add(sm); try { _context.SaveChanges(); } catch (DbEntityValidationException e) { Console.WriteLine(e); } return(0); }