public async Task <IActionResult> AddStudent(EnrollmentMusicClass enrollmentMusicClass) { enrollmentMusicClass.Date = DateTime.Now; if (ModelState.IsValid) { _context.Add(enrollmentMusicClass); await _context.SaveChangesAsync(); return(RedirectToAction("Edit", "MusicClasses", new { id = enrollmentMusicClass.MusicClassId })); } ViewData["EnrollmentId"] = new SelectList(_context.Enrollment, "EnrollmentId", "EnrollmentId", enrollmentMusicClass.EnrollmentId); ViewData["MusicClassId"] = new SelectList(_context.MusicClass, "MusicClassId", "MusicClassId", enrollmentMusicClass.MusicClassId); return(View(enrollmentMusicClass)); }
public async Task <IActionResult> Create(AddInstrumentViewModel vm) { int quantity = vm.Quantity; if (ModelState.IsValid) { for (int i = 0; i < quantity; i++) { InstrumentInventory instrumentInventory = new InstrumentInventory(); instrumentInventory.InstrumentId = vm.InstrumentId; instrumentInventory.Manufacturer = vm.Manufacturer; instrumentInventory.PurchaseDate = DateTime.Now; instrumentInventory.Cost = vm.Cost; _context.Add(instrumentInventory); } await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } foreach (var error in ViewData.ModelState.Values.SelectMany(modelState => modelState.Errors)) { var test = error; } ViewData["InstrumentId"] = new SelectList(_context.Instrument, "InstrumentId", "Instrument1", vm.InstrumentId); return(View(vm)); }
public async Task <IActionResult> Create([Bind("SheetMusicId,Title,Composer,Amount")] SheetMusic sheetMusic) { if (ModelState.IsValid) { _context.Add(sheetMusic); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(sheetMusic)); }
public async Task <IActionResult> Create([Bind("VenueId,VenueName")] Venue venue) { if (ModelState.IsValid) { _context.Add(venue); await _context.SaveChangesAsync(); return(RedirectToAction("Create", "Performances")); } return(View(venue)); }
public async Task <IActionResult> Create([Bind("EnsembleId,Type")] Ensemble ensemble) { if (ModelState.IsValid) { _context.Add(ensemble); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(ensemble)); }
public async Task <IActionResult> Create([Bind("PersonId,FirstName,LastName,Dob,Address")] Person person) { if (ModelState.IsValid) { _context.Add(person); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(person)); }
public async Task <IActionResult> Create([Bind("PieceId,Title,Composer,LastPerformedDate")] Piece piece) { if (ModelState.IsValid) { _context.Add(piece); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(piece)); }
public async Task <IActionResult> Create([Bind("ContactId,Email,Phone")] Contact contact) { if (ModelState.IsValid) { _context.Add(contact); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(contact)); }
public async Task <IActionResult> Create([Bind("InstrumentId,Instrument1,StudentFee,OpenFee,HireFee,HeadTutor")] Instrument instrument) { if (ModelState.IsValid) { _context.Add(instrument); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["HeadTutor"] = new SelectList(_context.Tutor, "TutorId", "TutorId", instrument.HeadTutor); return(View(instrument)); }
public async Task <IActionResult> Create([Bind("PayrollId,StaffId,Date,Amount,Notes")] Payroll payroll) { if (ModelState.IsValid) { _context.Add(payroll); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["StaffId"] = new SelectList(_context.Staff, "StaffId", "StaffId", payroll.StaffId); return(View(payroll)); }
public async Task <IActionResult> Create([Bind("EnsembleId,PerformanceId")] EnsemblePerformance ensemblePerformance) { if (ModelState.IsValid) { _context.Add(ensemblePerformance); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["EnsembleId"] = new SelectList(_context.Ensemble, "EnsembleId", "Type", ensemblePerformance.EnsembleId); ViewData["PerformanceId"] = new SelectList(_context.Performance, "PerformanceId", "PerformanceId", ensemblePerformance.PerformanceId); return(View(ensemblePerformance)); }
public async Task <IActionResult> Create([Bind("StaffId,PersonId,ContactId,StartDate,LeftDate,Hours")] Staff staff) { if (ModelState.IsValid) { _context.Add(staff); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["ContactId"] = new SelectList(_context.Contact, "ContactId", "Email", staff.ContactId); ViewData["PersonId"] = new SelectList(_context.Person, "PersonId", "Address", staff.PersonId); return(View(staff)); }
public async Task <IActionResult> Create([Bind("TutorId,InstrumentId,MaxGrade")] TutorType tutorType) { if (ModelState.IsValid) { _context.Add(tutorType); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["InstrumentId"] = new SelectList(_context.Instrument, "InstrumentId", "Instrument1", tutorType.InstrumentId); ViewData["TutorId"] = new SelectList(_context.Tutor, "TutorId", "TutorId", tutorType.TutorId); return(View(tutorType)); }
public async Task <IActionResult> Create([Bind("InstrumentInventoryId,TechnicianId,RepairStart,RepairEnd")] Repairs repairs) { if (ModelState.IsValid) { _context.Add(repairs); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["InstrumentInventoryId"] = new SelectList(_context.InstrumentInventory, "InstrumentInventoryId", "Manufacturer", repairs.InstrumentInventoryId); ViewData["TechnicianId"] = new SelectList(_context.Technician, "TechnicianId", "TechnicianId", repairs.TechnicianId); return(View(repairs)); }
public async Task <IActionResult> Create(PerformancePiece performancePiece) { Piece piece = await _context.Piece.FindAsync(performancePiece.PieceId); piece.LastPerformedDate = DateTime.Now; _context.Update(piece); await _context.SaveChangesAsync(); _context.Add(performancePiece); await _context.SaveChangesAsync(); return(RedirectToAction("Index", "Performances")); }
public async Task <IActionResult> Create([Bind("InstrumentInventoryId,EnrollmentId,DateLoaned,DateReturned")] Loan loan) { if (ModelState.IsValid) { _context.Add(loan); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["EnrollmentId"] = new SelectList(_context.Enrollment, "EnrollmentId", "EnrollmentId", loan.EnrollmentId); ViewData["InstrumentInventoryId"] = new SelectList(_context.InstrumentInventory, "InstrumentInventoryId", "Manufacturer", loan.InstrumentInventoryId); return(View(loan)); }
public async Task <IActionResult> Create([Bind("MusicClassId,TutorId,LessonTimeId,StartDate,EndDate")] MusicClass musicClass) { if (ModelState.IsValid) { _context.Add(musicClass); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["LessonTimeId"] = new SelectList(_context.LessonTime, "LessonTimeId", "LessonTimeId", musicClass.LessonTimeId); ViewData["TutorId"] = new SelectList(_context.Tutor, "TutorId", "TutorId", musicClass.TutorId); return(View(musicClass)); }
public async Task <IActionResult> Create(Enrollment enrollment) { enrollment.Paid = false; if (Request.Form["paid"] == "1") { enrollment.Paid = true; } enrollment.Date = DateTime.Now; ViewData["LoanError"] = null; var test = 1; if (Request.Form["loan"] == "1") { //Insert into LoanStudent here string proc = "[Loan Instrument] " + enrollment.EnrollmentId.ToString(); test = _context.Database.ExecuteSqlCommand(proc); } try { _context.Add(enrollment); await _context.SaveChangesAsync(); } catch (Exception e) { if (e is SqlException | e is DbUpdateException) { return(RedirectToAction("LoanError", new { errorMessage = "Enrollment already exists." })); } } if (test < 1) { return(RedirectToAction("LoanError", new { errorMessage = "No available instruments to loan." })); } return(RedirectToAction(nameof(Index))); //ViewData["InstrumentId"] = new SelectList(_context.Instrument, "InstrumentId", "Instrument1", enrollment.InstrumentId); //ViewData["StudentId"] = new SelectList(_context.Student, "StudentId", "StudentId", enrollment.StudentId); //System.Diagnostics.Debug.WriteLine("----------------------------------------------------------- " + ViewData["LoanError"]); //return View(enrollment); }
public async Task <IActionResult> Create([Bind("SheetMusicTutorId,SheetMusicId,TutorId,AmountLoaned")] SheetMusicTutor sheetMusicTutor) { sheetMusicTutor.DateLoaned = DateTime.Now; SheetMusic sm = await _context.SheetMusic.FirstOrDefaultAsync(s => s.SheetMusicId == sheetMusicTutor.SheetMusicId); sm.Amount -= sheetMusicTutor.AmountLoaned; if (sm.Amount >= 0) { if (ModelState.IsValid) { _context.Update(sm); _context.Add(sheetMusicTutor); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } } else { ViewData["Error"] = "Not enough copies to loan. Can only loan out copies in stock."; } List <SheetMusic> sheetMusic = _context.SheetMusic.ToList(); List <SheetMusicViewModel> sms = sheetMusic.Select(s => new SheetMusicViewModel { id = s.SheetMusicId, name = s.Title + " (" + s.Composer + ") - Quantity: " + (sm.Amount += sheetMusicTutor.AmountLoaned) }).ToList(); ViewData["SheetMusic"] = new SelectList(sms, "id", "name"); List <Tutor> tutors = _context.Tutor.Include(a => a.Staff.Person).ToList(); List <TutorViewModel> t = tutors.Select(s => new TutorViewModel { id = s.TutorId, name = s.Staff.Person.FirstName + " " + s.Staff.Person.LastName }).ToList(); ViewData["Tutor"] = new SelectList(t, "id", "name"); return(View(sheetMusicTutor)); }
public async Task <IActionResult> Create([Bind("PerformanceId,Date,Time,VenueId")] Performance performance) { _context.Performance.Add(performance); await _context.SaveChangesAsync(); List <Ensemble> ensembles = _context.Ensemble.ToList(); foreach (var item in ensembles) { //Person int id = item.EnsembleId; EnsemblePerformance ensemblePerformance = new EnsemblePerformance(); ensemblePerformance.EnsembleId = id; ensemblePerformance.Ensemble = await _context.Ensemble.FindAsync(id); ensemblePerformance.PerformanceId = performance.PerformanceId; _context.Add(ensemblePerformance); await _context.SaveChangesAsync(); } return(RedirectToAction("Details", new { id = performance.PerformanceId })); }