public async Task <IActionResult> Create([Bind("Id,ScheduleId,MemberEmail,CoachEmail")] ScheduleMembers scheduleMembers) { if (ModelState.IsValid) { _context.Add(scheduleMembers); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(scheduleMembers)); }
public async Task <IActionResult> Create([Bind("Id,When,Description,CoachEmail,Location")] Schedule schedule) { if (ModelState.IsValid) { _context.Add(schedule); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(schedule)); }
public async Task <IActionResult> Create([Bind("Id,Email,Biography,PhotoUrl")] Coach coach, IFormFile PhotoUrl) { if (ModelState.IsValid) { //upload an image if there isnt one, store it in wwwroot\images\coach if (PhotoUrl != null && PhotoUrl.Length > 0) { var fileName = Path.GetFileName(PhotoUrl.FileName); var filePath = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot\\images\\coach", fileName); using (var fileSteam = new FileStream(filePath, FileMode.Create)) { await PhotoUrl.CopyToAsync(fileSteam); } coach.PhotoUrl = fileName; } _context.Add(coach); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(coach)); }