public int Add(StudentProfileViewModel model, List <AcademicRecordsViewModel> records, GuardianViewModel gardian, InitialPaymentDetailViewModel officeFrom, int[] OriginalDocumentId) { return(_iStudent.Add(model, records, gardian, officeFrom, OriginalDocumentId)); }
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); }