Example #1
0
        public void Add(PersonViewModel personViewModel)
        {
            var config = _configuration.GetValue <string>("Config:AtletaBase64");


            personViewModel.Password = Divers.GenerateMD5(personViewModel.Password);

            if (personViewModel.Picture == "")
            {
                personViewModel.Picture = Divers.Base64ToImage(config, "PERSON");
            }
            else
            {
                personViewModel.Picture = Divers.Base64ToImage(personViewModel.Picture, "PERSON");
            }

            Person _person = _mapper.Map <Person>(personViewModel);

            _personRepository.Add(_person);

            foreach (var item in personViewModel.ProfileType)
            {
                PersonProfile _personProfile = new PersonProfile
                {
                    PersonId    = _person.Id,
                    ProfileType = (ProfileType)int.Parse(item)
                };

                _personProfileRepository.Add(_personProfile);
            }

            //var registerCommand = _mapper.Map<RegisterNewCustomerCommand>(personViewModel);
            //Bus.SendCommand(registerCommand);
        }
Example #2
0
        public void Update(TeamViewModel teamViewModel)
        {
            string[] symbol = teamViewModel.Symbol.Split('/');

            if (symbol[0] != "data:image")
            {
                teamViewModel.Symbol = symbol[symbol.Count() - 1];
            }
            else
            {
                teamViewModel.Symbol = Divers.Base64ToImage(teamViewModel.Symbol, "TEAM");
            }

            teamViewModel.Picture = "semimagem.png";

            _teamRepository.Update(_mapper.Map <Team>(teamViewModel));

            var result = _teamRepository.GetTeamPerson(teamViewModel.PersonId).Result;

            if (teamViewModel.Active)
            {
                foreach (var item in result.Where(p => p.Active == true && p.Id != teamViewModel.Id))
                {
                    item.Active = false;
                    _teamRepository.Update(item);
                }
            }
        }
Example #3
0
        public async Task <Person> UpdateUser(User user)
        {
            try
            {
                Person person = await Db.People.FindAsync(user.Id);

                Db.Entry(person).State = EntityState.Modified;

                person.Name      = user.Name;
                person.Phone     = user.Phone;
                person.BirthDate = user.BirthDate;
                person.Picture   = user.Picture;

                if (person.Password != "")
                {
                    person.Password = Divers.GenerateMD5(person.Password);
                }
                else
                {
                    Db.Entry(person).Property(x => x.Password).IsModified = false;
                }

                Db.SaveChanges();

                person.Password = "";
            }
            catch (System.Exception e)
            {
                e.Message.ToString();
                throw;
            }


            return(null);
        }
Example #4
0
        public async Task <PersonViewModel> SignIn(UserViewModel userViewModel)
        {
            userViewModel.Password = Divers.GenerateMD5(userViewModel.Password);

            Person person = await _personRepository.SignIn(_mapper.Map <User>(userViewModel));

            return(await _personAppService.GetProfileTeam(person));
        }
        public void Add(ChampionshipViewModel championshipViewModel)
        {
            var config = _configuration.GetValue <string>("Config:AtletaBase64");

            if (championshipViewModel.Picture == "")
            {
                championshipViewModel.Picture = Divers.Base64ToImage(config, "CHAMPIONSHIP");
            }
            else
            {
                championshipViewModel.Picture = Divers.Base64ToImage(championshipViewModel.Picture, "CHAMPIONSHIP");
            }

            _championshipRepository.Add(_mapper.Map <Championship>(championshipViewModel));
        }
        public void Update(ChampionshipViewModel championshipViewModel)
        {
            string[] symbol = championshipViewModel.Picture.Split('/');

            if (symbol[0] != "data:image")
            {
                championshipViewModel.Picture = symbol[symbol.Count() - 1];
            }
            else
            {
                championshipViewModel.Picture = Divers.Base64ToImage(championshipViewModel.Picture, "CHAMPIONSHIP");
            }

            _championshipRepository.Update(_mapper.Map <Championship>(championshipViewModel));
        }
Example #7
0
        public void Add(FieldViewModel fieldViewModel)
        {
            var config = _configuration.GetValue <string>("Config:AtletaBase64");

            if (fieldViewModel.Picture == "")
            {
                fieldViewModel.Picture = Divers.Base64ToImage(config, "FIELD");
            }
            else
            {
                fieldViewModel.Picture = Divers.Base64ToImage(fieldViewModel.Picture, "FIELD");
            }

            _fieldRepository.Add(_mapper.Map <Field>(fieldViewModel));
        }
Example #8
0
        public void Update(FieldViewModel fieldViewModel)
        {
            string[] symbol = fieldViewModel.Picture.Split('/');

            if (symbol[0] != "data:image")
            {
                fieldViewModel.Picture = symbol[symbol.Count() - 1];
            }
            else
            {
                fieldViewModel.Picture = Divers.Base64ToImage(fieldViewModel.Picture, "FIELD");
            }

            _fieldRepository.Update(_mapper.Map <Field>(fieldViewModel));
        }
Example #9
0
        public void Add(PlayerViewModel playerViewModel)
        {
            var config = _configuration.GetValue <string>("Config:AtletaBase64");

            if (playerViewModel.Picture == "")
            {
                playerViewModel.Picture = Divers.Base64ToImage(config, "PLAYER");
            }
            else
            {
                playerViewModel.Picture = Divers.Base64ToImage(playerViewModel.Picture, "PLAYER");
            }

            _playerRepository.Add(_mapper.Map <Player>(playerViewModel));
        }
Example #10
0
        public void Update(PlayerViewModel playerViewModel)
        {
            string[] picture = playerViewModel.Picture.Split('/');

            if (picture[0] != "data:image")
            {
                playerViewModel.Picture = picture[picture.Count() - 1];
            }
            else
            {
                playerViewModel.Picture = Divers.Base64ToImage(playerViewModel.Picture, "PLAYER");
            }

            _playerRepository.Update(_mapper.Map <Player>(playerViewModel));
        }
Example #11
0
        public override void Update(Person person)
        {
            Db.Entry(person).State = EntityState.Modified;

            if (person.Password != "")
            {
                person.Password = Divers.GenerateMD5(person.Password);
            }
            else
            {
                Db.Entry(person).Property(x => x.Password).IsModified = false;
            }

            Db.SaveChanges();
        }
Example #12
0
        public void UpdateProfile(PersonViewModel personViewModel)
        {
            string[] picture = personViewModel.Picture.Split('/');

            if (picture[0] != "data:image")
            {
                personViewModel.Picture = picture[picture.Count() - 1];
            }
            else
            {
                personViewModel.Picture = Divers.Base64ToImage(personViewModel.Picture, "PERSON");
            }

            Person person = _mapper.Map <Person>(personViewModel);

            _personRepository.Update(person);
        }
Example #13
0
        public void Add(TeamViewModel teamViewModel)
        {
            List <Team> list = _teamRepository.GetTeamPerson(teamViewModel.PersonId).Result.ToList();

            list.ForEach(m => m.Active = false);
            _teamRepository.UpdateRange(list);

            var config = _configuration.GetValue <string>("Config:AtletaBase64");

            if (teamViewModel.Symbol == "")
            {
                teamViewModel.Symbol = Divers.Base64ToImage(config, "TEAM");
            }
            else
            {
                teamViewModel.Symbol = Divers.Base64ToImage(teamViewModel.Symbol, "TEAM");
            }

            teamViewModel.Picture = "semimagem.png";


            _teamRepository.Add(_mapper.Map <Team>(teamViewModel));
        }
Example #14
0
        public void Update(PersonViewModel personViewModel)
        {
            var result = _personProfileRepository.GetAll().Result;

            string[] picture = personViewModel.Picture.Split('/');

            if (picture[0] != "data:image")
            {
                personViewModel.Picture = picture[picture.Count() - 1];
            }
            else
            {
                personViewModel.Picture = Divers.Base64ToImage(personViewModel.Picture, "PERSON");
            }

            Person _person = _mapper.Map <Person>(personViewModel);

            _personRepository.Update(_person);

            List <PersonProfile> personProfilesList = result.Where(p => p.PersonId == personViewModel.Id).ToList();

            _personProfileRepository.RemoveRange(personProfilesList);

            foreach (var item in personViewModel.ProfileType)
            {
                PersonProfile _personProfile = new PersonProfile
                {
                    PersonId    = _person.Id,
                    ProfileType = (ProfileType)int.Parse(item)
                };

                _personProfileRepository.Add(_personProfile);
            }

            //var updateCommand = _mapper.Map<UpdateCustomerCommand>(personViewModel);
            //Bus.SendCommand(updateCommand);
        }
Example #15
0
 /// <summary>
 /// Lägg till en hoppare på eventet
 /// </summary>
 /// <param name="diver"></param>
 public void AddDiver(Diver diver)
 {
     Divers.Add(diver);
 }
        public void AutomaticMatchChampionship(int championshipId, int groupId)
        {
            Random rnd          = new Random();
            int    quantityTeam = 0;
            int    round        = 0;
            int    count        = 0;
            int    turno        = 0;
            int    fieldId      = 0;

            List <int> teamSubscription = new List <int>();

            string[] matchs;


            var championship = _championshipRepository.GetById(championshipId).Result;

            switch (championship.ChampionshipType)
            {
            case ChampionshipType.Grupos:
                if (groupId == 0)
                {
                    throw new Exception();
                }
                else
                {
                    var resultGroupChampionship = _groupChampionshipRepository.GetAll().Result;
                    var groupChampionship       = resultGroupChampionship.Where(p => p.GroupId == (Group)groupId && p.Subscription.ChampionshipId == championshipId).ToList();

                    foreach (var e in groupChampionship)
                    {
                        teamSubscription.Add(e.SubscriptionId);
                        fieldId = e.Subscription.Championship.FieldId;
                    }
                }
                break;

            case ChampionshipType.MataMata:
                break;

            case ChampionshipType.PontosCorridos:
                var result        = _subscriptionRepository.GetAll().Result;
                var subscriptions = result.Where(p => p.ChampionshipId == championshipId);

                foreach (var e in subscriptions)
                {
                    teamSubscription.Add(e.Id);
                    fieldId = e.Championship.FieldId;
                }
                break;

            default:
                break;
            }

            quantityTeam = teamSubscription.Count();

            if (quantityTeam % 2 == 0)
            {
                round = quantityTeam - 1;
            }
            else
            {
                round = quantityTeam;
            }

            if (championship.GoBack)
            {
                turno  = 2;
                matchs = new string[Divers.CalculaFatorial(quantityTeam) / Divers.CalculaFatorial(quantityTeam - 2)];
            }
            else
            {
                turno  = 1;
                matchs = new string[Divers.CalculaFatorial(quantityTeam) / Divers.CalculaFatorial(quantityTeam - 2) / 2];
            }

            count = 0;

            for (int t = 0; t < turno; t++)
            {
                for (int i = 0; i < quantityTeam; i++)
                {     //For para caminhar entre os times
                    for (int j = i; j < quantityTeam; j++)
                    { //For para caminha entre os adversários
                        if (teamSubscription[i] != teamSubscription[j])
                        {
                            MatchChampionship matchChampionship = new MatchChampionship
                            {
                                HomeSubscriptionId  = teamSubscription[i],
                                GuestSubscriptionId = teamSubscription[j],
                                HomePoints          = 0,
                                GuestPoints         = 0,
                                MatchDate           = DateTime.Now,
                                RegisterDate        = DateTime.Now,
                                StartTime           = "",
                                Round = 0
                            };

                            _matchChampionshipRepository.Add(matchChampionship);

                            //Sumula sumula = new Sumula();

                            //sumula.IDPartidaCampeonato = partidaCampeonato.IDPartidaCampeonato;
                            //sumula.sObservacao = "";
                            //sumula.dDataCadastro = DateTime.Now;
                            //db.Sumula.Add(sumula);
                            //db.SaveChanges();
                        }
                    }
                }
            }

            if (quantityTeam % 2 == 0)
            {
                OrdenaRodada(championshipId, teamSubscription);
            }
            else
            {
                List <int> timesInscritosNew = new List <int>();

                foreach (int e in teamSubscription)
                {
                    timesInscritosNew[count] = e;
                    count++;
                }

                timesInscritosNew[teamSubscription.Count()] = 10000000;

                OrdenaRodada(championshipId, timesInscritosNew);
            }
        }