public void Promotion(List <StudentPromotionViewModel> model, int PSemesterId) { foreach (var item in model) { var currStd = _context.StudentSemesterMappings .Where(x => x.StudentId == item.StudentId && x.SemesterId == item.SemesterId && x.IsActive == item.IsActive).FirstOrDefault(); if (item.IsPromotion == true && currStd != null) { currStd.IsActive = false; _context.Entry(currStd).State = EntityState.Modified; _context.SaveChanges(); if (currStd.SemesterId != PSemesterId) { var proStd = new StudentSemesterMapping(); proStd.StudentId = item.StudentId; proStd.SemesterId = PSemesterId; proStd.IsActive = true; _context.StudentSemesterMappings.Add(proStd); _context.SaveChanges(); } } } }
public void Create(AdministratorVM model) { var adminProfile = new Administrator { Id = Guid.NewGuid(), FirstName = model.FirstName, LastName = model.LastName, ApplicationUserId = model.ApplicationUserId }; _context.Administrators.Add(adminProfile); _context.SaveChanges(); }
public void UpdateStudentProfile(StudentProfileViewModel model) { var std = _context.Students.Where(x => x.Id == model.Id).FirstOrDefault(); std.StdNameEnglish = model.StdNameEnglish; std.StdNameBangla = model.StdNameBangla; std.StdFatherNameEnglish = model.StdFatherNameEnglish; std.StdFatherNameBangla = model.StdFatherNameBangla; std.StdMotherNameBangla = model.StdMotherNameBangla; std.StdMotherNameEnglish = model.StdMotherNameEnglish; std.DateOfBirth = model.DateOfBirth; std.Phone = model.Phone; std.Picture = model.Picture; std.PermanentAddress = model.PermanentAddress; std.PresentAddress = model.PresentAddress; std.RegistrationNo = model.RegistrationNo; std.ExamRollNo = model.ExamRollNo; _context.Entry(std).State = EntityState.Modified; _context.SaveChanges(); }
public Guid AddPayment(PaymentTypeName model, List <PaymentTypeViewModel> ptvm, int[] noMonth) { Payment payment = new Payment(); payment.Id = Guid.NewGuid(); payment.InvoiceNo = RandomString(5); payment.StudentId = model.StudentId; payment.GrandTotal = model.TotalSemesterFees; payment.Discount = model.Discount; payment.PaidAmount = model.PaidAmount; payment.Due = model.Due; payment.PaymentDate = model.PaymentDate; payment.PaymentMethodId = model.PaymentMethodId; payment.SemesterId = model.SemesterId; if (model.PaymentMethodId == 2) { payment.BankId = model.BankId; payment.CheckNo = model.CheckNo; payment.CheckDate = model.CheckDate; } else { payment.BankId = 0; payment.CheckNo = null; payment.CheckDate = null; } _context.Payments.Add(payment); var stdSemester = from std in _context.Students.ToList() join smt in _context.Semesters.ToList() on std.SemesterId equals smt.Id where std.Id == model.StudentId select new { SemesterId = std.SemesterId }; foreach (var item in ptvm) { if ((item.Amount > 0 && item.IsChecked == true)) { if (item.Id == 3) { foreach (var pMonth in noMonth) { PaymentDetail pd = new PaymentDetail(); pd.PaymentTypeID = item.Id; pd.PayAmount = item.Amount; pd.PaymentsId = payment.Id; pd.PayMonth = pMonth; _context.PaymentDetails.Add(pd); } } else { PaymentDetail pd = new PaymentDetail(); pd.PaymentTypeID = item.Id; pd.PayAmount = item.Amount; pd.PaymentsId = payment.Id; _context.PaymentDetails.Add(pd); } } } _context.SaveChanges(); return(payment.Id); }