コード例 #1
0
ファイル: VoteBLL.cs プロジェクト: iondrimba/musicbattl
        public IVote VoteOnArtist(IVote vote)
        {
            IVote voteAdded = new Vote();

            IDataQuery query = new DataQuery();

            query.Where = string.Format("profileId={0} and songId={1} and battlId={2}", vote.ProfileId, vote.SongId, vote.BattlId);
            IVote result = _voteRepository.Find(query).FirstOrDefault();

            if (result != null)
            {
                vote.VoteId = result.VoteId;
                vote.Votes  = result.Votes + 1;
                voteAdded   = _voteRepository.Update(vote);
            }
            else
            {
                voteAdded = _voteRepository.Add(vote);
            }

            query.Where = string.Format("songId={0} and battlId={1}", vote.SongId, vote.BattlId);
            int resultTotal = CanGetVotesByWhere(query.Where).Sum(m => m.Votes);

            vote.Votes = resultTotal;

            return(voteAdded);
        }
コード例 #2
0
        public IViewBattl CreateBattl()
        {
            IDataQuery query = new DataQuery();

            query.Where = string.Format("ViewBattl.active=1");
            IViewBattl         _viewBattl = new ViewBattl();
            IList <IViewBattl> col        = _viewBattlRepository.Find(query);

            if (col.Count > 0)
            {
                _viewBattl = col[0];
            }
            else
            {
                IBattl   battl     = GetBattlNotPlayedThisWeek();
                DateTime battlTime = DateTime.Now; //GetLastBattlTime();
                battl.BattlDate = battlTime;
                battl.StartTime = new DateTime(battlTime.Year, battlTime.Month, battlTime.Day, battlTime.Hour, battlTime.Minute, 0);
                battl.EndTime   = battl.StartTime.AddSeconds(59);
                battl.Active    = true;

                using (TransactionScope scope = new TransactionScope())
                {
                    battl = _battlRepository.Add(battl);

                    query       = new DataQuery();
                    query.Where = string.Format("ViewBattl.BattlId={0} and active=1", battl.BattlId);
                    col         = _viewBattlRepository.Find(query);

                    if (col.Count > 0)
                    {
                        _viewBattl = col[0];
                    }

                    scope.Complete();
                }
            }

            return(_viewBattl);
        }
コード例 #3
0
ファイル: AccountBLL.cs プロジェクト: iondrimba/musicbattl
        public IProfile CreateAccount(AccountUser usuario)
        {
            IProfile result = new Profile();

            using (TransactionScope scope = new TransactionScope())
            {
                usuario.Created  = DateTime.Now;
                usuario.City     = Security.ClearSQLInjection(usuario.City);
                usuario.Country  = Security.ClearSQLInjection(usuario.Country);
                usuario.CustomId = Security.ClearSQLInjection(usuario.CustomId);
                usuario.Email    = Security.ClearSQLInjection(usuario.Email);
                usuario.Name     = Security.ClearSQLInjection(usuario.Name);
                usuario.Password = Security.ClearSQLInjection(usuario.Password);
                usuario.Picture  = Security.ClearSQLInjection(usuario.Picture);
                usuario.Gender   = Security.ClearSQLInjection(usuario.Gender);

                string emailcrypted = Security.Encrypt(usuario.Email);
                string passw        = PasswordHash.CreateHash(usuario.Password);

                usuario.Email    = emailcrypted;
                usuario.Password = passw;

                IUsuario iusuario = _repository.Add(usuario);

                ProfileRepository profile    = new ProfileRepository(_dataBase);
                IProfile          newProfile = new Profile();
                newProfile.UserId  = iusuario.UsuarioId;
                newProfile.Upadted = DateTime.Now;
                newProfile.Picture = Security.ClearSQLInjection(usuario.Picture);
                result             = profile.Add(newProfile);

                scope.Complete();
            }

            return(result);
        }