public void CreateTeams(GrowDbContext context, int contestId)
 {
     foreach (var team in TeamNames)
     {
         if (context.Teams.Any(t => t.Name.Equals(team, StringComparison.InvariantCultureIgnoreCase)))
         {
             continue;
         }
         context.Teams.Add(new Team()
         {
             Name      = team,
             ContestId = contestId,
             IsActive  = true
         });
     }
     context.SaveChanges();
 }
예제 #2
0
 public void SaveFile(Material material)
 {
     try
     {
         Material m = new Material()
         {
             Name = material.Name,
             Path = material.Path
         };
         _context.Material.Add(m);
         _context.SaveChanges();
     }
     catch (Exception)
     {
         throw;
     }
 }
예제 #3
0
        public void UpdateTeam(Team oldTeam, TeamViewModel newViewModel)
        {
            if (oldTeam.Id != newViewModel.Id)
            {
                throw new ArgumentException("Can't update a different team");
            }

            oldTeam.ActiveSince  = newViewModel.ActiveSince;
            oldTeam.Description  = newViewModel.Description;
            oldTeam.Email        = newViewModel.Email;
            oldTeam.FacebookUrl  = newViewModel.FacebookUrl;
            oldTeam.InstagramUrl = newViewModel.InstagramUrl;
            oldTeam.Members      = newViewModel.Members.Where(m => !string.IsNullOrWhiteSpace(m)).ToList();
            oldTeam.Name         = newViewModel.Name;
            oldTeam.TagLine      = newViewModel.TagLine;
            oldTeam.WebsiteUrl   = newViewModel.WebsiteUrl;

            UpdateTeamPhoto(oldTeam, newViewModel);
            UpdateLogoImage(oldTeam, newViewModel);

            _dbContext.SaveChanges();
        }
        User IAuthService.RegisterUser(string userName, string password, string fname, string lname, string confirmPassword, string avtar)
        {
            try
            {
                var user = new User()
                {
                    UserName        = userName,
                    Password        = password,
                    FirstName       = fname,
                    LastName        = lname,
                    ConfirmPassword = confirmPassword,
                    Avtar           = avtar,
                };

                _context.User.Add(user);
                _context.SaveChanges();

                return(user);
            }
            catch (Exception)
            {
                throw;
            }
        }