Exemplo n.º 1
0
        public async Task Update(Training training)
        {
            if (training == null)
            {
                throw new ArgumentNullException(nameof(training));
            }

            Training trainingInDb = _trainingContext.Trainings.FirstOrDefault(t => t.TrainingID == training.TrainingID);

            if (trainingInDb == null)
            {
                throw new ArgumentNullException(nameof(trainingInDb));
            }

            trainingInDb.TimeAndDateOfTraining = training.TimeAndDateOfTraining;
            trainingInDb.Coach  = training.Coach;
            trainingInDb.Member = training.Member;
            trainingInDb.Sport  = training.Sport;

            _trainingContext.Attach(trainingInDb).State = EntityState.Modified;
            await _trainingContext.SaveChangesAsync();
        }
        public async Task Update(Coach coach)
        {
            if (coach == null)
            {
                throw new ArgumentNullException(nameof(coach));
            }

            Coach coachInDb = _trainingContext.Coaches.FirstOrDefault(c => c.CoachID == coach.CoachID);

            if (coachInDb == null)
            {
                throw new ArgumentNullException(nameof(coachInDb));
            }

            coachInDb.FullName    = coach.FullName;
            coachInDb.PhoneNumber = coach.PhoneNumber;
            coachInDb.Email       = coach.Email;
            coachInDb.Experience  = coach.Experience;
            coachInDb.Trainings   = coach.Trainings;

            _trainingContext.Attach(coachInDb).State = EntityState.Modified;
            await _trainingContext.SaveChangesAsync();
        }
        public async Task Update(Sport sport)
        {
            if (sport == null)
            {
                throw new ArgumentNullException(nameof(sport));
            }

            Sport sportInDb = _trainingContext.Sports.FirstOrDefault(s => s.SportID == sport.SportID);

            if (sportInDb == null)
            {
                throw new ArgumentNullException(nameof(sportInDb));
            }

            sportInDb.SportsName           = sport.SportsName;
            sportInDb.Description          = sport.Description;
            sportInDb.Difficult            = sport.Difficult;
            sportInDb.MonthlyMembershipFee = sport.MonthlyMembershipFee;
            sportInDb.Trainings            = sport.Trainings;

            _trainingContext.Attach(sportInDb).State = EntityState.Modified;
            await _trainingContext.SaveChangesAsync();
        }
Exemplo n.º 4
0
        public async Task Update(Member member)
        {
            if (member == null)
            {
                throw new ArgumentNullException(nameof(member));
            }

            Member memberInDb = _trainingContext.Members.FirstOrDefault(m => m.MemberID == member.MemberID);

            if (memberInDb == null)
            {
                throw new ArgumentNullException(nameof(memberInDb));
            }

            memberInDb.MemberID       = member.MemberID;
            memberInDb.FullName       = member.FullName;
            memberInDb.PhoneNumber    = member.PhoneNumber;
            memberInDb.Email          = member.Email;
            memberInDb.MembershipType = member.MembershipType;
            memberInDb.Trainings      = member.Trainings;

            _trainingContext.Attach(memberInDb).State = EntityState.Modified;
            await _trainingContext.SaveChangesAsync();
        }