Esempio n. 1
0
        public async Task WHEN_all_ParkEvents_are_requested_THEN_all_ParkEvents_are_returned()
        {
            // arrange

            var e1 = new ParkEvent
            {
                EventId              = 1000,
                Name                 = "An event in a park",
                Park                 = new Park(),
                Date                 = DateTime.MaxValue,
                Description          = "skdlfgkjsdlfkgjhsdlfkjghsdlkfjg",
                OrganiserFirstName   = "Wendy",
                OrganiserLastName    = "Addams",
                OrganiserEmail       = "[email protected]",
                OrganiserPhoneNumber = "07000000000"
            };
            var e2 = new ParkEvent
            {
                EventId              = 1001,
                Name                 = "An event in a park two",
                Park                 = new Park(),
                Date                 = DateTime.MaxValue.AddDays(-1),
                Description          = "skdlfgkjsdlfkgjjhjhjhjhhsdlfkjghsdlkfjg",
                OrganiserFirstName   = "Mandy",
                OrganiserLastName    = "Yandy",
                OrganiserEmail       = "*****@*****.**",
                OrganiserPhoneNumber = "07000000000"
            };
            var e3 = new ParkEvent
            {
                EventId              = 1002,
                Name                 = "An event in a park three",
                Park                 = new Park(),
                Date                 = DateTime.MaxValue.AddDays(-2),
                Description          = "skdlfgkjsdlfkgjhslkjhdlfkjghsdlkfjg",
                OrganiserFirstName   = "Bill",
                OrganiserLastName    = "Markup",
                OrganiserEmail       = "*****@*****.**",
                OrganiserPhoneNumber = "07000120000"
            };

            _repository.Add(e1);
            _repository.Add(e2);
            await _repository.SaveChangesAsync();

            // act

            var result = await _repository.GetAllEventsAsync();

            // assert

            Assert.NotEmpty(result);
            Assert.Contains(e1, result);
            Assert.Contains(e2, result);
            Assert.DoesNotContain(e3, result);
        }
Esempio n. 2
0
        public static ParkEvent AddEventRec(ParkEvent mode, out string ErrorMessage)
        {
            if (mode == null)
            {
                throw new ArgumentNullException("mode");
            }

            IParkEvent factory = ParkEventFactory.GetFactory();

            return(factory.AddEventRec(mode, out ErrorMessage));
        }
Esempio n. 3
0
        public async Task WHEN_repostory_is_queried_for_parkEvent_with_eventId_THEN_parkEvent_with_eventId_is_returned()
        {
            // arrange

            var e1 = new ParkEvent
            {
                EventId              = 1010,
                Name                 = "An event in a park one one",
                Park                 = new Park(),
                Date                 = DateTime.MaxValue.AddDays(-10),
                Description          = "skdlfgkjsdlfkgjhsdlfkjghsdlkfjg",
                OrganiserFirstName   = "Wendy",
                OrganiserLastName    = "Addams",
                OrganiserEmail       = "[email protected]",
                OrganiserPhoneNumber = "07000000000"
            };
            var e2 = new ParkEvent
            {
                EventId              = 1011,
                Name                 = "An event in a park two one",
                Park                 = new Park(),
                Date                 = DateTime.MaxValue.AddDays(-11),
                Description          = "skdlfgkjsdlfkgjjhjhjhjhhsdlfkjghsdlkfjg",
                OrganiserFirstName   = "Mandy",
                OrganiserLastName    = "Yandy",
                OrganiserEmail       = "*****@*****.**",
                OrganiserPhoneNumber = "07000000000"
            };

            _repository.Add(e1);
            _repository.Add(e2);
            await _repository.SaveChangesAsync();

            // act

            var result1 = await _repository.GetEventByIdAsync(1010);

            var result2 = await _repository.GetEventByIdAsync(1011);

            var result3 = await _repository.GetEventByIdAsync(1012);

            // assert

            Assert.NotNull(result1);
            Assert.NotNull(result2);
            Assert.Null(result3);
            Assert.Equal(e1, result1);
            Assert.Equal(e2, result2);
        }
Esempio n. 4
0
        public async Task WHEN_repostory_is_queried_for_parkEvents_with_date_THEN_all_parkEvent_with_date_are_returned()
        {
            // arrange

            var e1 = new ParkEvent
            {
                EventId              = 1020,
                Name                 = "An event in a park",
                Park                 = new Park(),
                Date                 = DateTime.MaxValue.AddDays(-20),
                Description          = "skdlfgkjsdlfkgjhsdlfkjghsdlkfjg",
                OrganiserFirstName   = "Wendy",
                OrganiserLastName    = "Addams",
                OrganiserEmail       = "[email protected]",
                OrganiserPhoneNumber = "07000000000"
            };
            var e2 = new ParkEvent
            {
                EventId              = 1021,
                Name                 = "An event in a park two",
                Park                 = new Park(),
                Date                 = DateTime.MaxValue.AddDays(-21),
                Description          = "skdlfgkjsdlfkgjjhjhjhjhhsdlfkjghsdlkfjg",
                OrganiserFirstName   = "Mandy",
                OrganiserLastName    = "Yandy",
                OrganiserEmail       = "*****@*****.**",
                OrganiserPhoneNumber = "07000000000"
            };
            var e3 = new ParkEvent
            {
                EventId              = 1022,
                Name                 = "An event in a park three",
                Park                 = new Park(),
                Date                 = DateTime.MaxValue.AddDays(-20),
                Description          = "skdlfgkjsdlfkgjhslkjhdlfkjghsdlkfjg",
                OrganiserFirstName   = "Bill",
                OrganiserLastName    = "Markup",
                OrganiserEmail       = "*****@*****.**",
                OrganiserPhoneNumber = "07000120000"
            };

            _repository.Add(e1);
            _repository.Add(e2);
            _repository.Add(e3);
            await _repository.SaveChangesAsync();

            // act

            var result1 = await _repository.GetEventsByDateAsync(DateTime.MaxValue.AddDays(-20));

            var result2 = await _repository.GetEventsByDateAsync(DateTime.MaxValue.AddDays(-21));

            var result3 = await _repository.GetEventsByDateAsync(DateTime.MaxValue.AddDays(-22));

            // assert

            Assert.NotEmpty(result1);
            Assert.NotEmpty(result2);
            Assert.Empty(result3);
            Assert.Contains(e1, result1);
            Assert.Contains(e3, result1);
            Assert.Contains(e2, result2);
            Assert.DoesNotContain(e3, result2);
        }
Esempio n. 5
0
        public ParkEvent AddEventRec(ParkEvent model, out string ErrorMessage)
        {
            ErrorMessage = "";
            try
            {
                using (DbOperator dbOperator = ConnectionManager.CreateConnection())
                {
                    model.DataStatus     = (int)DataStatus.Normal;
                    model.LastUpdateTime = DateTime.Now;
                    model.HaveUpdate     = SystemDefaultConfig.DataUpdateFlag;
                    model.RecordID       = GuidGenerator.GetGuidString();
                    StringBuilder strSql = new StringBuilder();
                    strSql.Append("insert into ParkEvent(RecordID,CardNo,CardNum,CarModelID,CarTypeID,DataStatus,EmployeeName,EventID,GateID,HaveUpdate,IORecordID,IOState,LastUpdateTime,OperatorID,ParkingID,PictureName,PlateColor,PlateNumber,RecTime,Remark,IsScanCode,IsOffline,CertNo,CertName,CertificateImage,Address,BirthDate,Nation,Sex)");
                    strSql.Append(" values(@RecordID,@CardNo,@CardNum,@CarModelID,@CarTypeID,@DataStatus,@EmployeeName,@EventID,@GateID,@HaveUpdate,@IORecordID,@IOState,@LastUpdateTime,@OperatorID,@ParkingID,@PictureName,@PlateColor,@PlateNumber,@RecTime,@Remark,@IsScanCode,@IsOffline,@CertNo,@CertName,@CertificateImage,@Address,@BirthDate,@Nation,@Sex);");
                    strSql.Append(" select * from ParkEvent where RecordID=@RecordID ");
                    dbOperator.ClearParameters();
                    dbOperator.AddParameter("RecordID", model.RecordID);
                    dbOperator.AddParameter("CardNo", model.CardNo);
                    dbOperator.AddParameter("CardNum", model.CardNum);
                    dbOperator.AddParameter("CarModelID", model.CarModelID);
                    dbOperator.AddParameter("CarTypeID", model.CarTypeID);
                    dbOperator.AddParameter("DataStatus", model.DataStatus);
                    dbOperator.AddParameter("EmployeeName", model.EmployeeName);
                    dbOperator.AddParameter("EventID", model.EventID);
                    dbOperator.AddParameter("GateID", model.GateID);
                    dbOperator.AddParameter("HaveUpdate", model.HaveUpdate);
                    dbOperator.AddParameter("IORecordID", model.IORecordID);
                    dbOperator.AddParameter("IOState", model.IOState);
                    dbOperator.AddParameter("LastUpdateTime", model.LastUpdateTime);
                    dbOperator.AddParameter("OperatorID", model.OperatorID);
                    dbOperator.AddParameter("ParkingID", model.ParkingID);
                    dbOperator.AddParameter("PictureName", model.PictureName);
                    dbOperator.AddParameter("PlateColor", model.PlateColor);
                    dbOperator.AddParameter("PlateNumber", model.PlateNumber);
                    dbOperator.AddParameter("RecTime", model.RecTime);
                    dbOperator.AddParameter("Remark", model.Remark);
                    dbOperator.AddParameter("IsScanCode", model.IsScanCode);
                    dbOperator.AddParameter("IsOffline", model.IsOffline);

                    dbOperator.AddParameter("CertNo", model.CertNo);
                    dbOperator.AddParameter("CertName", model.CertName);
                    dbOperator.AddParameter("CertificateImage", model.CertificateImage);
                    dbOperator.AddParameter("Address", model.Address);
                    dbOperator.AddParameter("BirthDate", model.BirthDate);
                    dbOperator.AddParameter("Nation", model.Nation);
                    dbOperator.AddParameter("Sex", model.Sex);
                    using (DbDataReader reader = dbOperator.ExecuteReader(strSql.ToString()))
                    {
                        if (reader.Read())
                        {
                            return(DataReaderToModel <ParkEvent> .ToModel(reader));
                        }
                    }
                }
            }
            catch (Exception e)
            {
                ErrorMessage = e.Message;
            }
            return(null);
        }