Esempio n. 1
0
        public AdminSeasonEditViewModel GetAdminSeasonEditViewModel(int id)
        {
            var viewModel = new AdminSeasonEditViewModel()
            {
                CurrentSeasonId = id,
                NewDivision     = new Divisions(),
                SeasonDivisions = _context.Divisions.Where(d => d.SeasonId == id).ToList()
            };

            return(viewModel);
        }
Esempio n. 2
0
 public void AddNewDivision(AdminSeasonEditViewModel viewModel)
 {
     if (viewModel.NewDivision.DivisionName != string.Empty)
     {
         if (
             !_context.Divisions.Any(
                 d => d.DivisionName.Equals(viewModel.NewDivision.DivisionName) && d.SeasonId == viewModel.CurrentSeasonId))
         {
             viewModel.NewDivision.SeasonId = viewModel.CurrentSeasonId;
             _context.Divisions.Add(viewModel.NewDivision);
             _context.SaveChanges();
         }
     }
 }