예제 #1
0
 /// <summary>
 /// Gets the hash code
 /// </summary>
 /// <returns>Hash code</returns>
 public override int GetHashCode()
 {
     unchecked // Overflow is fine, just wrap
     {
         var hashCode = 41;
         // Suitable nullity checks etc, of course :)
         if (Id != null)
         {
             hashCode = hashCode * 59 + Id.GetHashCode();
         }
         if (ShipId != null)
         {
             hashCode = hashCode * 59 + ShipId.GetHashCode();
         }
         if (ShipName != null)
         {
             hashCode = hashCode * 59 + ShipName.GetHashCode();
         }
         if (BookingDate != null)
         {
             hashCode = hashCode * 59 + BookingDate.GetHashCode();
         }
         if (Price != null)
         {
             hashCode = hashCode * 59 + Price.GetHashCode();
         }
         return(hashCode);
     }
 }
예제 #2
0
        public bool Update(Booking booking)
        {
            bool shouldUpdate = false;

            if (!Notes.Equals(booking.Notes, StringComparison.OrdinalIgnoreCase))
            {
                Notes        = booking.Notes;
                shouldUpdate = true;
            }

            if (!BookingDate.Equals(booking.BookingDate))
            {
                BookingDate  = booking.BookingDate;
                shouldUpdate = true;
            }

            if (!ClientId.Equals(booking.ClientId))
            {
                ClientId     = booking.ClientId;
                shouldUpdate = true;
            }

            if (!VehicleId.Equals(booking.ClientId))
            {
                VehicleId    = booking.VehicleId;
                shouldUpdate = true;
            }

            return(shouldUpdate);
        }
예제 #3
0
        /// <summary>
        /// Returns true if Booking instances are equal
        /// </summary>
        /// <param name="other">Instance of Booking to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(Booking other)
        {
            if (ReferenceEquals(null, other))
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     Id == other.Id ||
                     Id != null &&
                     Id.Equals(other.Id)
                     ) &&
                 (
                     ShipId == other.ShipId ||
                     ShipId != null &&
                     ShipId.Equals(other.ShipId)
                 ) &&
                 (
                     BookingDate == other.BookingDate ||
                     BookingDate != null &&
                     BookingDate.Equals(other.BookingDate)
                 ) &&
                 (
                     Price == other.Price ||
                     Price != null &&
                     Price.Equals(other.Price)
                 ));
        }
예제 #4
0
        public void ChangeBooking_BookingWithDifferentCurrency_PaymentNotSameCurrencyAsAccountException()
        {
            //Arrange
            var bookingIdGuid = Guid.Parse("b9c18f4d-8f11-408d-be7c-c7f022abefb2");
            var bookingId     = BookingId.FromGuid(bookingIdGuid);
            var payment       = Payment.FromDecimal(100.00m, "EUR");
            var bookingDate   = BookingDate.FromString("2020-09-26");
            var description   = Description.FromString("My payment");

            var accountIdGuid = Guid.Parse("9ccf4aa8-cd1e-4044-a183-464c8a8730ec");
            var account       = AccountRoot.Create(
                AccountId.FromGuid(accountIdGuid),
                UserId.FromGuid(Guid.Parse("13f172e2-7189-4506-b232-894bafcd4449")),
                Period.FromMonth(2020, 9),
                CurrencyCode.FromString("EUR"));

            account.BookPayment(bookingId, payment, bookingDate, description);

            var changedPayment     = Payment.FromDecimal(200.00m, "USD");
            var changedBookingDate = BookingDate.FromString("2020-09-01");
            var changedDescription = Description.FromString("My payment changed");

            //Act & Assert
            Assert.Throws <PaymentNotSameCurrencyAsAccountException>(() => account.ChangeBooking(bookingId, changedPayment, changedBookingDate, changedDescription));
        }
        public virtual int _GetUniqueIdentifier()
        {
            var hashCode = 399326290;

            hashCode = hashCode * -1521134295 + (Id?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (BookingDate?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (OrderNo?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (NoIdentity?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (FromExtTime?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (ToExtTime?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (BookStatus?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (NoPlatform?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (NoCourier?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (Warehouse?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (Driver?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (DriverTelephone?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (Plate?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (Trailerplate?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (PalletIN?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (TotalPallet?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (DateArrived?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (TimeArrived?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (DateExit?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (TImeExit?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (RouteTracking_ID?.GetHashCode() ?? 0);
            return(hashCode);
        }
예제 #6
0
        public async void BookCarForDate(BookingDate curDate, int id)
        {
            var content = new StringContent(JsonSerializer.Serialize(curDate), Encoding.UTF8, "application/json");
            await HttpClient.PutAsync("api/cars/" + id + "/book", content);

            GetCarsFromDate();
        }
예제 #7
0
        /// <summary>
        /// Returns the range of booking dates for the specified time period and event. From and to are inclusive,
        /// i.e. they can be the same to get the schedule for a single day.
        /// </summary>
        /// <param name="from">The start date of the time period.</param>
        /// <param name="to">The end date of the time period.</param>
        /// <param name="event">The event for which to determine the available schedule.</param>
        /// <returns>A list of booking dates.</returns>
        public IList <BookingDate> GetBookingDateRange(DateTime from, DateTime to, Event @event)
        {
            var dates = new List <BookingDate>();
            var day   = new DateTime(from.Ticks);

            CheckIfDatesValid(from, to);
            InitializeProviders(from, to);

            while (day <= to)
            {
                foreach (var time in times)
                {
                    var availability = new BookingDate();

                    availability.Date   = new DateTime(day.Year, day.Month, day.Day, time.Hours, time.Minutes, 0);
                    availability.Status = DetermineStatus(day, time, @event);

                    dates.Add(availability);
                }

                day = day.AddDays(1);
            }

            return(dates);
        }
예제 #8
0
        public void ChangeBooking_BookingDoesNotExist_InvalidOperationException()
        {
            //Arrange
            var bookingIdGuid = Guid.Parse("b9c18f4d-8f11-408d-be7c-c7f022abefb2");
            var bookingId     = BookingId.FromGuid(bookingIdGuid);
            var payment       = Payment.FromDecimal(100.00m, "EUR");
            var bookingDate   = BookingDate.FromString("2020-09-26");
            var description   = Description.FromString("My payment");

            var accountIdGuid = Guid.Parse("9ccf4aa8-cd1e-4044-a183-464c8a8730ec");
            var account       = AccountRoot.Create(
                AccountId.FromGuid(accountIdGuid),
                UserId.FromGuid(Guid.Parse("13f172e2-7189-4506-b232-894bafcd4449")),
                Period.FromMonth(2020, 9),
                CurrencyCode.FromString("EUR"));

            account.BookPayment(bookingId, payment, bookingDate, description);

            var nonExistingBookingId = BookingId.FromGuid(Guid.Parse("58bead84-e4d6-481b-9c7a-b52a36a98c3f"));
            var changedPayment       = Payment.FromDecimal(200.00m, "EUR");
            var changedBookingDate   = BookingDate.FromString("2020-09-01");
            var changedDescription   = Description.FromString("My payment changed");

            //Act & Assert
            Assert.Throws <InvalidOperationException>(() => account.ChangeBooking(nonExistingBookingId, changedPayment, changedBookingDate, changedDescription));
        }
예제 #9
0
        public async Task <Car> BookCar(int carId, DateTime bookingdate)
        {
            Car c = context.Cars.Include(car => car.BookingDates).Where(c => c.CarId == carId).FirstOrDefault();

            if (c == null)
            {
                throw new CarDoesNotExistException();
            }
            if (c.BookingDates == null)
            {
                c.BookingDates = new List <BookingDate>();
            }
            if (ConvertToDateTimeList(c.BookingDates).Contains(bookingdate.Date))
            {
                throw new AlreadyBookedException();
            }
            if (DateTime.Compare(bookingdate.Date, DateTime.Now.Date) < 0)
            {
                throw new InvalidDateException();
            }
            BookingDate bk = new BookingDate();

            bk.BookDate = bookingdate;
            c.BookingDates.Add(bk);
            context.Cars.Update(c);
            await context.SaveChangesAsync();

            return(c);
        }
        public void BookingDate_FromDate_DefaultDate_ArgumentNullException()
        {
            //Arrange
            var dte = DateTime.MinValue;

            //Act & Assert
            Assert.Throws <ArgumentNullException>(() => BookingDate.FromDate(dte));
        }
        public void BookingDate_FromString_InvalidDate_ArgumentNullException()
        {
            //Arrange
            const string dte = "hello";

            //Act & Assert
            Assert.Throws <FormatException>(() => BookingDate.FromString(dte));
        }
예제 #12
0
 // method for clear the details in from
 public void clear()
 {
     tbBookingID.Clear();
     tbMemberName.Clear();
     tbFacilityName.Clear();
     BookingDate.Clear();
     tbSlotTime.Clear();
     tbStatus.Clear();
 }
        protected async override Task <AccountRoot> Apply(ChangePaymentCommand command, CancellationToken cancellationToken)
        {
            AggregateRoot.ChangeBooking(
                Domain.BookingId.FromGuid(command.BookingId),
                Payment.FromDecimal(command.AccountItemDto.Amount, AggregateRoot.Currency.Value),
                BookingDate.FromDate(command.AccountItemDto.Date),
                Description.FromString(command.AccountItemDto.Description));

            return(await Task.FromResult(AggregateRoot));
        }
예제 #14
0
        private void BookCar(object sender, RoutedEventArgs e)
        {
            int         id      = (int)(((Button)sender).Tag);
            BookingDate curDate = new BookingDate
            {
                Date = Date
            };

            BookCarForDate(curDate, id);
        }
        public void BookingDate_FromString_ValidDate_Created()
        {
            //Arrange
            var dte = DateTime.Parse("2020-09-26");

            //Act
            var bookingDate = BookingDate.FromString("2020-09-26");

            //Assert
            Assert.AreEqual(dte, bookingDate.Value);
        }
예제 #16
0
        public override string ToString()
        {
            List <string> stringPackages = new List <string>();
            string        packages       = string.Empty; // The combined string, providing all the packageNames

            foreach (Package package in Packages)
            {
                packages += "\n" + package.Name + ",";
            }
            // Split[nrs]       0                   1                                   2                               3                     4                     5                       6                   7                       8                                   9                               10                         11
            return("        " + Id + ";" + Customer.CustomerName + ";" + BookingDate.ToString("yyyy:MM:dd") + ";" + StartTime + ";" + Customer.Email + ";" + Customer.Telephone + ";" + Customer.Vat + ";" + packages + ";" + Customer.Vehicle.LicensePlate + ";" + Customer.Vehicle.Brand + ";" + Customer.CustomerId + ";" + Customer.Vehicle.VehicleId);
        }
예제 #17
0
        public void ChangeBooking_ValidParams_BookingAddedToAccount()
        {
            //Arrange
            var bookingIdGuid = Guid.Parse("b9c18f4d-8f11-408d-be7c-c7f022abefb2");
            var bookingId     = BookingId.FromGuid(bookingIdGuid);
            var payment       = Payment.FromDecimal(100.00m, "EUR");
            var bookingDate   = BookingDate.FromString("2020-09-26");
            var description   = Description.FromString("My payment");

            var accountIdGuid = Guid.Parse("9ccf4aa8-cd1e-4044-a183-464c8a8730ec");
            var account       = AccountRoot.Create(
                AccountId.FromGuid(accountIdGuid),
                UserId.FromGuid(Guid.Parse("13f172e2-7189-4506-b232-894bafcd4449")),
                Period.FromMonth(2020, 9),
                CurrencyCode.FromString("EUR"));

            account.BookPayment(bookingId, payment, bookingDate, description);

            var changedPayment     = Payment.FromDecimal(200.00m, "EUR");
            var changedBookingDate = BookingDate.FromString("2020-09-20");
            var changedDescription = Description.FromString("My payment changed");

            //Act
            account.ChangeBooking(bookingId, changedPayment, changedBookingDate, changedDescription);

            //Assert
            Assert.IsNotNull(account.Bookings);
            Assert.IsNotNull(account.Bookings[0]);
            var booking = account.Bookings[0];

            Assert.AreEqual(bookingIdGuid, booking.Id.Value);
            Assert.AreEqual(200.00m, booking.Payment.Amount);
            Assert.AreEqual("EUR", booking.Payment.CurrencyCode);
            Assert.AreEqual(DateTime.Parse("2020-09-20"), booking.Date.Value);
            Assert.AreEqual("My payment changed", booking.Description.Value);
            Assert.AreEqual(3, account.GetChanges().Count);
            Assert.AreEqual(typeof(V1.BookingChanged), account.GetChanges()[2].GetType());
            var @event = account.GetChanges()[2] as V1.BookingChanged;

            Assert.AreEqual(accountIdGuid, @event.AccountId);
            Assert.AreEqual(bookingIdGuid, @event.BookingId);
            Assert.AreEqual(200.00m, @event.Amount);
            Assert.AreEqual("EUR", @event.CurrencyCode);
            Assert.AreEqual(DateTime.Parse("2020-09-20"), @event.Date);
            Assert.AreEqual("My payment changed", @event.Description);
        }
예제 #18
0
        public void BookPayment_PaymentDateOutsidePeriod_InvalidEntityStateException()
        {
            //Arrange
            var bookingIdGuid = Guid.Parse("b9c18f4d-8f11-408d-be7c-c7f022abefb2");
            var bookingId     = BookingId.FromGuid(bookingIdGuid);
            var payment       = Payment.FromDecimal(100.00m, "EUR");
            var bookingDate   = BookingDate.FromString("2020-01-01");
            var description   = Description.FromString("My payment");

            var accountIdGuid = Guid.Parse("9ccf4aa8-cd1e-4044-a183-464c8a8730ec");
            var account       = AccountRoot.Create(
                AccountId.FromGuid(accountIdGuid),
                UserId.FromGuid(Guid.Parse("13f172e2-7189-4506-b232-894bafcd4449")),
                Period.FromMonth(2020, 9),
                CurrencyCode.FromString("EUR"));

            //Act & Assert
            Assert.Throws <InvalidEntityState>(() => account.BookPayment(bookingId, payment, bookingDate, description));
        }
예제 #19
0
    //void DisplayCarReg()
    //{
    //    //create an instance of the car park collection
    //    clscarparkCollection carpark = new clscarparkCollection();
    //    //set the data source  to the list box
    //    LstCarReg.DataSource = carpark.CarParkList;
    //    //set the name of the primary key
    //    LstCarReg.DataValueField = "CarParkID";
    //    //Set the data field to display
    //    LstCarReg.DataTextField = "CarReg";
    //    //bind the data to the text
    //    LstCarReg.DataBind();
    //}

    // function to populate the list box
    Int32 DisplayCarReg(string CarRegFilter)
    {
        // create an instance of the car park cloolection
        clscarparkCollection carreg = new clscarparkCollection();
        // var for record count
        Int32 RecordCount;
        // var for first name
        string   CarReg;
        Int32    CarParkId;
        DateTime BookingDate;
        DateTime StartDate;
        DateTime EndDate;
        string   Price;
        // var for Index
        Int32 Index = 0;

        // clear the list of any existing item
        LstCarReg.Items.Clear();
        // call the filter method by staff last name
        carreg.FilterByCarReg(CarRegFilter);
        // get the count of records
        RecordCount = carreg.Count;
        // loop through each record found using the index
        while (Index < RecordCount)
        {
            // get the first name of the staff member
            CarReg      = Convert.ToString(carreg.CarParkList[Index].CarReg);
            CarParkId   = Convert.ToInt32(carreg.CarParkList[Index].carparkid);
            BookingDate = Convert.ToDateTime(carreg.CarParkList[Index].BookingDate.ToShortDateString());
            StartDate   = Convert.ToDateTime(carreg.CarParkList[Index].StartDate);
            EndDate     = Convert.ToDateTime(carreg.CarParkList[Index].EndDate);
            Price       = Convert.ToString(carreg.CarParkList[Index].Price);
            ListItem NewItem = new ListItem(CarReg + "........................." + BookingDate.ToShortDateString() + ".................................." + StartDate.ToShortDateString() + ".............................." + EndDate.ToShortDateString() + "................." + Price, CarParkId.ToString());
            // add the item to the list
            LstCarReg.Items.Add(NewItem);
            // increment the index
            Index++;
        }
        // return the number of records found
        return(RecordCount);
    }
예제 #20
0
        public void Close_StateClosedAmountSumOfBookings()
        {
            //Arrange
            var idGuid    = Guid.Parse("051f8160-ce43-4ac0-b8c2-09707c2bcda3");
            var id        = AccountId.FromGuid(idGuid);
            var ownerGuid = Guid.Parse("4bc0c0e9-7181-45e4-934d-e91c0e7bbd75");
            var ownerId   = UserId.FromGuid(ownerGuid);
            var period    = Period.FromMonth(2020, 9);
            var currency  = CurrencyCode.FromString("EUR");

            var account = AccountRoot.Create(id, ownerId, period, currency);

            account.BookPayment(
                BookingId.FromGuid(Guid.Parse("9d8d8a72-59a0-4a1b-8b86-94960df74586")),
                Payment.FromDecimal(10.00m, "EUR"),
                BookingDate.FromString("2020-09-01"),
                Description.FromString("Booking1"));

            account.BookPayment(
                BookingId.FromGuid(Guid.Parse("cbf7333e-3a7a-4bf9-ac85-4bdb22f7afb0")),
                Payment.FromDecimal(5.10m, "EUR"),
                BookingDate.FromString("2020-09-02"),
                Description.FromString("Booking2"));

            account.BookPayment(
                BookingId.FromGuid(Guid.Parse("07a94bd6-ae33-4765-9d1d-5257297e7ed0")),
                Payment.FromDecimal(8.43m, "EUR"),
                BookingDate.FromString("2020-09-03"),
                Description.FromString("Booking3"));

            //Act
            account.Close();

            //Assert
            Assert.AreEqual(AccountState.AccountStateEnum.Closed, account.State.Value);
            Assert.IsTrue(account.GetChanges().Last() is V1.AccountClosed);
            var @event = account.GetChanges().Last() as V1.AccountClosed;

            Assert.AreEqual(idGuid, @event.AccountId);
        }
예제 #21
0
        public void DeleteBooking_NonExistingBookingId_InvalidOperationException()
        {
            //Arrange
            var bookingIdGuid = Guid.Parse("b9c18f4d-8f11-408d-be7c-c7f022abefb2");
            var bookingId     = BookingId.FromGuid(bookingIdGuid);
            var payment       = Payment.FromDecimal(100.00m, "EUR");
            var bookingDate   = BookingDate.FromString("2020-09-26");
            var description   = Description.FromString("My payment");

            var accountIdGuid = Guid.Parse("9ccf4aa8-cd1e-4044-a183-464c8a8730ec");
            var account       = AccountRoot.Create(
                AccountId.FromGuid(accountIdGuid),
                UserId.FromGuid(Guid.Parse("13f172e2-7189-4506-b232-894bafcd4449")),
                Period.FromMonth(2020, 9),
                CurrencyCode.FromString("EUR"));

            account.BookPayment(bookingId, payment, bookingDate, description);

            var nonExistingBookingId = BookingId.FromGuid(Guid.Parse("2a5be36a-618e-48d1-a0e7-a184f2081a72"));

            //Act & Assert
            Assert.Throws <InvalidOperationException>(() => account.DeleteBooking(nonExistingBookingId));
        }
예제 #22
0
        public void DeleteBooking_ExistingBookingId_BookingRemoved()
        {
            //Arrange
            var bookingIdGuid = Guid.Parse("b9c18f4d-8f11-408d-be7c-c7f022abefb2");
            var bookingId     = BookingId.FromGuid(bookingIdGuid);
            var payment       = Payment.FromDecimal(100.00m, "EUR");
            var bookingDate   = BookingDate.FromString("2020-09-26");
            var description   = Description.FromString("My payment");

            var accountIdGuid = Guid.Parse("9ccf4aa8-cd1e-4044-a183-464c8a8730ec");
            var account       = AccountRoot.Create(
                AccountId.FromGuid(accountIdGuid),
                UserId.FromGuid(Guid.Parse("13f172e2-7189-4506-b232-894bafcd4449")),
                Period.FromMonth(2020, 9),
                CurrencyCode.FromString("EUR"));

            account.BookPayment(bookingId, payment, bookingDate, description);

            //Act
            account.DeleteBooking(bookingId);

            //Assert
            Assert.AreEqual(0, account.Bookings.Count);
        }