Ejemplo n.º 1
0
        public async Task <IActionResult> AddLesson(Lesson lesson)
        {
            db.Add(lesson);
            await db.SaveChangesAsync();

            return(RedirectToAction("AllLesson"));
        }
Ejemplo n.º 2
0
        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.Name = swimmer.Name;
                db.Update(swimmerToUpdate);
            }
            else
            {
                db.Add(swimmer);
            }
            await db.SaveChangesAsync();

            return(View("Index"));
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> AddProfile(Coach coach)
        {
            var currentUserId = this.User.FindFirst(ClaimTypes.NameIdentifier).Value;

            if (db.Coaches.Any(c => c.UserId == currentUserId))
            {
                var coachToUpdate = db.Coaches.FirstOrDefault(c => c.UserId == currentUserId);
                coachToUpdate.Name        = coach.Name;
                coachToUpdate.PhoneNumber = coach.PhoneNumber;
                db.Update(coachToUpdate);
            }
            else
            {
                db.Add(coach);
            }
            await db.SaveChangesAsync();

            return(View("Index"));
        }