public async Task <IActionResult> Create([Bind("Id,Name")] TrekkingAgency trekkingAgency) { if (ModelState.IsValid) { _context.Add(trekkingAgency); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(trekkingAgency)); }
public async Task <IActionResult> Create([Bind("Id,Name,Height,ClimbingStatus,FirstAscentYear")] Peak peak) { if (ModelState.IsValid) { _context.Add(peak); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(peak)); }
public async Task <IActionResult> Create([Bind("Id,StartDate,TerminationReason,OxygenUsed,PeakId,TrekkingAgencyId")] Expedition expedition) { if (ModelState.IsValid) { if (expedition.StartDate.Value.Month >= 3 && expedition.StartDate.Value.Month <= 5) { expedition.Season = "Spring"; expedition.Year = expedition.StartDate.Value.Year; } else if (expedition.StartDate.Value.Month >= 6 && expedition.StartDate.Value.Month <= 8) { expedition.Season = "Summer"; expedition.Year = expedition.StartDate.Value.Year; } else if (expedition.StartDate.Value.Month >= 9 && expedition.StartDate.Value.Month <= 11) { expedition.Season = "Fall"; expedition.Year = expedition.StartDate.Value.Year; } else if (expedition.StartDate.Value.Month == 12) { expedition.Season = "Winter"; expedition.Year = expedition.StartDate.Value.Year; } else if (expedition.StartDate.Value.Month == 1 || expedition.StartDate.Value.Month == 2) { expedition.Season = "Winter"; expedition.Year = expedition.StartDate.Value.Year - 1; } else { Debug.WriteLine("SOMETHING SUPER WRONG HAPPENED"); } _context.Add(expedition); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["PeakId"] = new SelectList(_context.Peaks, "Id", "Name", expedition.PeakId); ViewData["TrekkingAgencyId"] = new SelectList(_context.TrekkingAgencies, "Id", "Name", expedition.TrekkingAgencyId); return(View(expedition)); }