Beispiel #1
0
 public void UpdateRental(RentalRepresentation rental)
 {
     using (ISQLConnection dataSource = DataSource)
     {
         dataSource.UpdateRental(RepresentationConverter.convertRental(rental));
     }
 }
        public static Rentals convertRental(RentalRepresentation rental)
        {
            Rentals convertedRental = new Rentals()
            {
                actualPrice   = rental.actualPrice,
                customerID    = rental.customer.id,
                discount      = (float)rental.discount * 100,
                isClean       = rental.isClean,
                rentalID      = rental.id,
                rentalEnd     = rental.rentalEnd,
                isPaid        = rental.isPaid,
                payTypeID     = rental.payType.id,
                rentalRealEnd = rental.rentalRealEnd,
                rentalStart   = rental.rentalStart,
                toolID        = rental.tool.id
            };

            if (rental.group != null && rental.group.id != default(long))
            {
                convertedRental.groupID = rental.group.id;
            }

            convertedRental.Tools = convertTool(rental.tool);

            if (rental.customer.isFirm && rental.contact != null)
            {
                convertedRental.contactID  = rental.contact.id;
                convertedRental.Customers1 = convertCustomer(rental.contact);
            }

            return(convertedRental);
        }
Beispiel #3
0
        public NewRent_ViewModel()
        {
            if (!this.IsInDesignMode)
            {
                //t = new Timer(300000);
                //t.Start();
                //t.Elapsed += new ElapsedEventHandler(t_Elapsed);

                payType        = DataProxy.Instance.GetPayTypes();
                newRentalGroup = new RentalGroup_Representation();
                newRental      = new RentalRepresentation();

                selectedPayType   = payType.SingleOrDefault(pt => pt.id == 1);
                newRental.payType = selectedPayType;

                //changeEnabled = true;
            }
        }
        public static RentalGroup_Representation convertRentalGroup(RentalGroups rentalGroup)
        {
            RentalGroup_Representation convertedRentalGroup = new RentalGroup_Representation()
            {
                comment = rentalGroup.comment,
                deposit = rentalGroup.deposit ?? 0,
                id      = rentalGroup.groupID,
                isOpen  = rentalGroup.isOpen
            };

            foreach (Rentals rental in rentalGroup.Rentals)
            {
                RentalRepresentation rentalToAdd = convertRental(rental);
                rentalToAdd.group = convertedRentalGroup;
                convertedRentalGroup.rentals.Add(rentalToAdd);
            }

            return(convertedRentalGroup);
        }
        public static RentalRepresentation convertRental(Rentals rental)
        {
            RentalRepresentation convertedRental = new RentalRepresentation()
            {
                actualPrice = rental.actualPrice,
                contact     = convertCustomer(rental.Customers1),
                customer    = convertCustomer(rental.Customers),
                discount    = rental.discount / 100,
                //group = DataProxy.Instance.GetRentalGroupById(rental.groupID),    - Couses infinite cycle
                isClean       = rental.isClean,
                id            = rental.rentalID,
                isPaid        = rental.isPaid,
                payType       = convertPayType(rental.PayTypes),
                rentalEnd     = rental.rentalEnd,
                rentalRealEnd = rental.rentalRealEnd,
                rentalStart   = rental.rentalStart,
                tool          = convertTool(rental.Tools)
            };

            //int selfIndex = convertedRental.group.rentals.IndexOf(convertedRental.group.rentals.SingleOrDefault(r => r.id == convertedRental.id));
            //convertedRental.group.rentals[selfIndex] = convertedRental;

            return(convertedRental);
        }
Beispiel #6
0
 public static void Send(RentalRepresentation r)
 {
     Messenger.Default.Send(r, MessageTypes.newRentRemoved);
 }