Example #1
0
        public PartyInfo GetPartyInfo(int partyId)
        {
            var party = PartyRepository.GetPartyById(partyId);

            if (party != null && party.STATUS != (int)PartyStatuses.DELETED)
            {
                var info = new PartyInfo
                {
                    PartyId               = party.PARTY_ID,
                    InitiatorName         = party.DUOJU_USERS.NICK_NAME,
                    HoldDate              = party.HOLD_DATE,
                    HoldTime              = party.HOLD_TIME,
                    Description           = party.DESCRIPTION,
                    MinIntoForce          = party.MIN_INTO_FORCE,
                    MaxIntoForce          = party.MAX_INTO_FORCE,
                    Status                = party.STATUS,
                    SupplierInfo          = SupplierService.GetSupplierInfoById(party.SUPPLIER_ID),
                    PartyParticipantInfos = GetPartyParticipantInfos(partyId),
                    PartyCommentInfos     = party.STATUS == (int)PartyStatuses.CONSUMED ? PartyRepository.GetPartyCommentInfos(partyId) : null
                };

                ConvertPartyInfo(info);
                return(info);
            }

            return(null);
        }
Example #2
0
        public static void Seed(EvotingContext context)
        {
            const int count                  = 5;
            var       candidates             = new List <Candidate>();
            var       constituencyRepository = new ConstituencyRepository(context);
            var       partyRepository        = new PartyRepository(context);


            for (var i = 1; i <= count; i++)
            {
                var constituency = constituencyRepository.GetConstituencyById(Faker.RandomNumber.Next(1, 5));
                var party        = partyRepository.GetPartyById(Faker.RandomNumber.Next(1, 5));

                var candidate = new Candidate
                {
                    Constituency = constituency,
                    FirstName    = Faker.Name.First(),
                    LastName     = Faker.Name.Last(),
                    NumVotes     = 0,
                    Party        = party
                };
                candidates.Add(candidate);
            }
            candidates.ForEach(c => context.Candidates.Add(c));
            context.SaveChanges();
        }
Example #3
0
        public int AddPartyComment(CommentPartyInfo commentInfo)
        {
            var user  = UserRepository.GetUserByOpenId(commentInfo.OpenId);
            var party = PartyRepository.GetPartyById(commentInfo.PartyId.Value);

            if (!party.DUOJU_PARTY_PARTICIPANTS.Where(i => i.STATUS == (int)PartyParticipantStatuses.PARTICIPATED).Select(i => i.PARTICIPANT_ID).Contains(user.USER_ID))
            {
                throw new NotParticipantException();
            }
            else
            {
                var comment = new DUOJU_PARTY_COMMENTS
                {
                    DUOJU_SUPPLIERS  = party.DUOJU_SUPPLIERS,
                    DUOJU_USERS      = user,
                    CONTENT          = commentInfo.Content,
                    STATUS           = (int)PartyCommentStatuses.PUBLISHED,
                    CREATE_BY        = user.USER_ID,
                    CREATE_TIME      = DateTime.Now,
                    LAST_UPDATE_BY   = user.USER_ID,
                    LAST_UPDATE_TIME = DateTime.Now
                };
                party.DUOJU_PARTY_COMMENTS.Add(comment);

                PartyRepository.SaveChanges();

                return(party.PARTY_ID);
            }
        }
Example #4
0
        private async Task GetTrips()
        {
            bool canRun = true;

            this.Loading = true;
            RaisePropertyChanged("Loading");

            await Task.Run(async() =>
            {
                List <Trip> trips = await TripRepository.GetTrips();

                trips_all = new List <Trip.All>();

                if (trips == null || trips.Count == 0)
                {
                    this.Error   = "Geen trips gevonden";
                    canRun       = false;
                    this.Loading = false;
                    RaiseAll();
                    return;
                }

                var count = trips.Count;
                if ((trips.Count >= 10) && canRun == true)
                {
                    count = 10;
                }

                for (int i = 0; i < count; i++)
                {
                    Task <User.All> user = Task.FromResult <User.All>(await UsersRepository.GetUserById(trips[i].Users_ID));
                    Task <Bob.All> bob   = Task.FromResult <Bob.All>(await BobsRepository.GetBobById(trips[i].Bobs_ID));
                    Task <Users_Destinations> destination = Task.FromResult <Users_Destinations>(await DestinationRepository.GetDestinationById((trips[i].Destinations_ID)));
                    Task <Party> party = Task.FromResult <Party>(await PartyRepository.GetPartyById(trips[i].Party_ID));
                    Trip.All newTrip   = new Trip.All();


                    newTrip.Trip        = trips[i];
                    newTrip.User        = user.Result;
                    newTrip.Bob         = bob.Result;
                    newTrip.Party       = party.Result;
                    newTrip.Destination = destination.Result;
                    trips_all.Add(newTrip);
                }


                this.Trips   = trips_all;
                canRun       = false;
                this.Loading = false;


                RaiseAll();
            });
        }
Example #5
0
        public ConfirmPartyInfo ConfirmParty(int partyId, string openId)
        {
            var party = PartyRepository.GetPartyById(partyId);

            if (party == null)
            {
                throw new CanNotFindPartyException();
            }
            else
            {
                if (party.DUOJU_USERS.OPEN_ID != openId)
                {
                    throw new NoPartySInitiatorException();
                }
                else if (party.STATUS == (int)PartyStatuses.CONFIRMED)
                {
                    return new ConfirmPartyInfo
                           {
                               IdentifierNO = party.DUOJU_IDENTIFIERS.IDENTIFIER_NO,
                               ExpiresTime  = party.DUOJU_IDENTIFIERS.EXPIRES_TIME
                           }
                }
                ;

                var expiresTime = DateTime.Now.AddDays(CommonSettings.IDENTIFIEREXPIRESTIME_DAY_PARTY);
                expiresTime = new DateTime(expiresTime.Year, expiresTime.Month, expiresTime.Day).AddDays(1).AddSeconds(-1);
                var identifier = IdentifierService.GenerateIdentifier(IdentifierTypes.PARTY, expiresTime, new List <KeyValuePair <string, string> >
                {
                    new KeyValuePair <string, string>(CommonSettings.IDENTIFIERSETTINGCODE_PARTYID, partyId.ToString())
                }, party.CREATE_BY);

                party.DUOJU_IDENTIFIERS = identifier;
                party.STATUS            = (int)PartyStatuses.CONFIRMED;
                party.LAST_UPDATE_BY    = party.CREATE_BY;
                party.LAST_UPDATE_TIME  = DateTime.Now;

                PartyRepository.SaveChanges();

                return(new ConfirmPartyInfo
                {
                    IdentifierNO = identifier.IDENTIFIER_NO,
                    ExpiresTime = identifier.EXPIRES_TIME
                });
            }
        }
Example #6
0
        //Methods
        private async Task GetCurrentTrip()
        {
            this.Loading = true;
            RaisePropertyChanged("Loading");

            await Task.Run(async() =>
            {
                Trip currenttrip = Task.FromResult <Trip>(await TripRepository.GetCurrentTrip()).Result;
                if (currenttrip != null)
                {
                    if (currenttrip.Active == true)
                    {
                        Trip.All trips_all = new Trip.All();


                        User.All user = await UsersRepository.GetUserById(currenttrip.Users_ID);
                        Bob.All bob   = await BobsRepository.GetBobById(currenttrip.Bobs_ID);
                        Users_Destinations destination = await DestinationRepository.GetDestinationById((currenttrip.Destinations_ID));
                        Party party      = await PartyRepository.GetPartyById(currenttrip.Party_ID);
                        Trip.All newTrip = new Trip.All();



                        newTrip.Trip        = currenttrip;
                        newTrip.Party       = party;
                        newTrip.User        = user;
                        newTrip.Bob         = bob;
                        newTrip.Destination = destination;

                        MoveCar(newTrip.Trip.Status_Name);
                        this.CurrentTrip = newTrip;
                    }
                    else
                    {
                        this.CurrentTrip = null;
                        //geen current trip nu
                    }
                }
                RaiseAll();
            });
        }
Example #7
0
        public PartyParticipateCountInfo ParticipateParty(int partyId, string openId)
        {
            var user = UserRepository.GetUserByOpenId(openId);

            if (user == null || user.SUBSCRIBED == YesNo.N.ToString())
            {
                throw new UserDidNotConcernException();
            }

            var party = PartyRepository.GetPartyById(partyId);

            if (party == null)
            {
                throw new CanNotFindPartyException();
            }
            else
            {
                if (party.STATUS == (int)PartyStatuses.PUBLISHED)
                {
                    var validParticipants = party.DUOJU_PARTY_PARTICIPANTS.Where(i => i.PARTY_ID == partyId && i.STATUS == (int)PartyParticipantStatuses.PARTICIPATED);
                    var participant       = validParticipants.FirstOrDefault(i => i.PARTICIPANT_ID == user.USER_ID);

                    participant = null;
                    if (participant != null && participant.STATUS == (int)PartyParticipantStatuses.PARTICIPATED)
                    {
                        throw new UserHasBeenParticipateThePartyException();
                    }

                    if (participant == null)
                    {
                        participant = new DUOJU_PARTY_PARTICIPANTS
                        {
                            DUOJU_USERS = user,
                            CREATE_BY   = user.USER_ID,
                            CREATE_TIME = DateTime.Now
                        };

                        party.DUOJU_PARTY_PARTICIPANTS.Add(participant);
                        if (party.MAX_INTO_FORCE.HasValue && validParticipants.Count() + 1 >= party.MAX_INTO_FORCE.Value)
                        {
                            party.STATUS           = (int)PartyStatuses.FULLED;
                            party.LAST_UPDATE_BY   = user.USER_ID;
                            party.LAST_UPDATE_TIME = DateTime.Now;
                        }
                    }

                    participant.PARTICIPATE_TIME = DateTime.Now;
                    participant.STATUS           = (int)PartyParticipantStatuses.PARTICIPATED;
                    participant.LAST_UPDATE_BY   = user.USER_ID;
                    participant.LAST_UPDATE_TIME = DateTime.Now;

                    PartyRepository.SaveChanges();
                    return(new PartyParticipateCountInfo
                    {
                        InitiatorOpenId = party.DUOJU_USERS.OPEN_ID,
                        MinIntoForce = party.MIN_INTO_FORCE,
                        MaxIntoForce = party.MAX_INTO_FORCE,
                        ParticipateCount = party.DUOJU_PARTY_PARTICIPANTS.Count
                    });
                }
                else if (party.STATUS == (int)PartyStatuses.DELETED)
                {
                    throw new CanNotFindPartyException();
                }
                else
                {
                    throw new PartyWasClosedException();
                }
            }
        }