public async Task <IActionResult> AddLesson(Lesson lesson) { db.Add(lesson); await db.SaveChangesAsync(); return(RedirectToAction("AllLesson")); }
public async Task <IActionResult> AddProfile(Coach coach) { var currentUserId = this.User.FindFirst(ClaimTypes.NameIdentifier).Value; if (db.Coachs.Any(i => i.UserId == currentUserId)) { var coachToUpdate = db.Coachs.FirstOrDefault(i => i.UserId == currentUserId); coachToUpdate.CoachName = coach.CoachName; coachToUpdate.CoachPhone = coach.CoachPhone; db.Update(coachToUpdate); } else { coach.UserId = currentUserId; db.Add(coach); } await db.SaveChangesAsync(); return(View("Index")); }
public async Task <IActionResult> AddProfile(Swimmer swimmer) { var currentUserId = this.User.FindFirst (ClaimTypes.NameIdentifier).Value; if (db.Swimmers.Any(i => i.UserId == currentUserId)) { var swimmerToUpdate = db.Swimmers.FirstOrDefault (i => i.UserId == currentUserId); swimmerToUpdate.SwimmerName = swimmer.SwimmerName; swimmerToUpdate.SwimmerPhone = swimmer.SwimmerPhone; db.Update(swimmerToUpdate); } else { swimmer.UserId = currentUserId; db.Add(swimmer); } await db.SaveChangesAsync(); return(View("Index")); }