Exemplo n.º 1
0
        public void AddVote(int surveyId, int userId)
        {
            var userVote = new VotingLIstTable
            {
                IdSurvey = surveyId,
                IdUser   = userId,
                VoteTime = IsraelTimeZone.Now()
            };

            _service.Add(userVote);
        }
Exemplo n.º 2
0
        private void IsDateValid(DateTime start, DateTime end)
        {
            if (start > end)
            {
                throw new ArgumentException("End time is Earlier then Start Time");
            }

            if (IsraelTimeZone.Now() > start)
            {
                throw new ArgumentException("Start time as been pass");
            }
        }
Exemplo n.º 3
0
        public void AddVote(UserVote vote)
        {
            var user   = _userService.GetUser(vote.IdUser);
            var survey = GetSurvey(vote.IdSurvey);

            if (survey.EndTime < IsraelTimeZone.Now())
            {
                throw new SurveyException("Voting has ended");
            }

            if (user.Type > survey.TypeMember)
            {
                throw new SurveyException("You not Allow to vote on this Survey");
            }

            IsVoteLegal(vote);

            UpdateSurveyVote(survey, vote.Vote);
            _voteService.AddVote(survey.IdSurvey, vote.IdUser);
        }
Exemplo n.º 4
0
        public void AddSurvey(SurveyDto survey)
        {
            var user = _userService.GetUser(survey.IdUser);

            if (user.Type != (int)UserType.Admin)
            {
                throw new SurveyException("Only administrator allow to add Survey");
            }

            if (survey.StartTime > survey.EndTime)
            {
                throw new SurveyException("End time is earlier then Start time");
            }

            if (IsraelTimeZone.Now() > survey.StartTime)
            {
                throw new SurveyException("Start Time have pass already");
            }

            base.Add(survey);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Add new user to database
        /// </summary>
        /// <param name="user">details of a new user</param>
        /// <returns>true if succeed</returns>
        public bool Register(UserRegistertionData user)
        {
            var checkUser = base.SelectFirst(u => u.Email == user.Email);

            if (checkUser != null && checkUser.IsActive)
            {
                throw new RegistrationException("User is exist");
            }

            user.IsActive  = true;
            user.StartTime = IsraelTimeZone.Now();
            user.Type      = 3;

            if (checkUser != null && !checkUser.IsActive)
            {
                user.IdUser = checkUser.IdUser;
                UpdateUser(user);
                return(true);
            }

            base.Add(user);

            return(true);
        }
Exemplo n.º 6
0
 public void UpdateMessage(TK message)
 {
     message.ModifiedMessage = IsraelTimeZone.Now();
     base.Update(message);
 }
Exemplo n.º 7
0
 public void AddNewMessage(TK message)
 {
     message.ModifiedMessage = IsraelTimeZone.Now();
     base.Add(message);
 }