//// GET: Paiment/Create public async Task <PartialViewResult> Create(int?id) { var model = new CreatePaiementModel(); if (id != null) { var student = await stu.GetByIdAsync(id.Value); model.StudentNumber = student.StudentNumber; model.ActionFrom = "Student"; model.StudentID = student.Id; } else { model.ActionFrom = "Paiement"; } model.DateofPaiement = DateTime.UtcNow.Date; InitializeDropdownList(null, null, null, 2); return(PartialView(model)); }
public async Task <IActionResult> Create(CreatePaiementModel paiment) { if (ModelState.IsValid) { var model = new Paiment(); if (paiment.ActionFrom == "Paiement") { model.StudentID = await stu.GetStudentId(paiment.StudentNumber); model.MonthId = paiment.Period; model.Type = paiment.Type; model.PaidOn = paiment.DateofPaiement; model.Amount = paiment.Amount; Pmt.Add(model); await Pmt.SaveChangesAsync(); return(RedirectToAction("PayHistoric", new RouteValueDictionary( new { Controller = "Paiment", action = "PayHistoric", Id = paiment.StudentID }))); } else { model.StudentID = paiment.StudentID; model.MonthId = paiment.Period; model.Type = paiment.Type; model.PaidOn = paiment.DateofPaiement; model.Amount = paiment.Amount; Pmt.Add(model); await Pmt.SaveChangesAsync(); return(RedirectToAction("PayHistoric", new RouteValueDictionary( new { Controller = "Paiment", action = "PayHistoric", Id = paiment.StudentID }))); } } InitializeDropdownList(paiment.Period, paiment.Type, null, 2); return(View(paiment)); }