Esempio n. 1
0
        public int AddCompetition(CompetitionViewModel model)
        {
            FootballCompetition competition = AutoMapper.Mapper.Map <FootballCompetition>(model);

            UnitOfWork.FootballCompetitions.Add(competition);
            UnitOfWork.SaveChanges();

            return(competition.Id);
        }
Esempio n. 2
0
        public void UpdateCompetition(CompetitionViewModel model)
        {
            FootballCompetition competition = UnitOfWork.FootballCompetitions.FirstOrDefault(x => x.Id == model.Id);

            if (competition == null)
            {
                throw new ArgumentNullException("There is no such item in database");
            }

            competition.Name = model.Name;
            competition.CompetitionImageUrl = model.CompetitionImageUrl;
            competition.IsActive            = model.IsActive;
            competition.LocationId          = model.LocationId;

            UnitOfWork.SaveChanges();
        }
Esempio n. 3
0
        public void DeleteCompetition(int competitionId)
        {
            FootballCompetition competition = UnitOfWork.FootballCompetitions.FirstOrDefault(x => x.Id == competitionId);

            if (competition == null)
            {
                throw new ArgumentNullException("There is no such item in database");
            }

            if (competition.Cultures.Count > 0)
            {
                UnitOfWork.FootballCompetitionCultures.RemoveRange(competition.Cultures);
            }

            UnitOfWork.FootballCompetitions.Remove(competition);

            UnitOfWork.SaveChanges();
        }