Beispiel #1
0
        public static CreateBillableItemResponse ToCreateBillableItemResponse(BillableItem entity)
        {
            var response = new CreateBillableItemResponse();

            switch (entity.BillToType.ToUpper())
            {
            case EntityType.ACCOUNT_ENTITY:
                response.BillToType = EntityType.ACCOUNT_ENTITY;
                response.BillToId   = entity.BillToAccountEntityId;
                response.BillToName = entity.BillToAccountEntity?.Name;
                break;

            case EntityType.VENDOR:
                response.BillToType = EntityType.VENDOR;
                response.BillToId   = entity.BillToVendorId;
                response.BillToName = entity.BillToVendor?.Name;
                break;

            case EntityType.TRANSFEREE:
                response.BillToType = EntityType.TRANSFEREE;
                response.BillToId   = entity.BillToTransfereeId;
                response.BillToName = string.Concat(entity.BillToTransferee?.FirstName, " ", entity.BillToTransferee?.LastName);
                break;
            }

            return(response);
        }
Beispiel #2
0
        public static GetBillableItemResponse ToGetBillableItemResponse(BillableItem entity)
        {
            var response = new GetBillableItemResponse();

            switch (entity.BillToType.ToUpper())
            {
            case EntityType.ACCOUNT_ENTITY:
                response.BillToType  = EntityType.ACCOUNT_ENTITY;
                response.BillToId    = entity.BillToAccountEntityId;
                response.BillToName  = entity.BillToAccountEntity?.Name;
                response.BillToLabel = $"{EntityType.ACCOUNT_ENTITY}-{entity.BillToAccountEntityId}";
                break;

            case EntityType.VENDOR:
                response.BillToType  = EntityType.VENDOR;
                response.BillToId    = entity.BillToVendorId;
                response.BillToName  = entity.BillToVendor?.Name;
                response.BillToLabel = $"{EntityType.VENDOR}-{entity.BillToVendorId}";
                break;

            case EntityType.TRANSFEREE:
                response.BillToType  = EntityType.TRANSFEREE;
                response.BillToId    = entity.BillToTransfereeId;
                response.BillToName  = $"{entity.BillToTransferee?.FirstName} {entity.BillToTransferee?.LastName}";
                response.BillToLabel = $"{EntityType.TRANSFEREE}-{entity.BillToTransfereeId}";
                break;
            }

            return(response);
        }
Beispiel #3
0
        public static BillableItem ToBillableItem(GetBillableItemResponse dto)
        {
            var response = new BillableItem();

            switch (dto.BillToType.ToUpper())
            {
            case EntityType.ACCOUNT_ENTITY:
                response.BillToType            = EntityType.ACCOUNT_ENTITY;
                response.BillToAccountEntityId = dto?.BillToId;
                break;

            case EntityType.VENDOR:
                response.BillToType     = EntityType.VENDOR;
                response.BillToVendorId = dto?.BillToId;
                break;

            case EntityType.TRANSFEREE:
                response.BillToType         = EntityType.TRANSFEREE;
                response.BillToTransfereeId = dto?.BillToId;
                break;
            }

            return(response);
        }
Beispiel #4
0
        //takes data from dataSet and uses it to populate classes
        private void ConvertData()
        {
            //Create and store hotel classes
            for (int i = 0; i < dataSet.Tables[0].Rows.Count; i++)
            {
                Hotel hotel = new Hotel(Int32.Parse(dataSet.Tables[0].Rows[i][0].ToString()), dataSet.Tables[0].Rows[i][1].ToString(), Int32.Parse(dataSet.Tables[0].Rows[i][2].ToString()), dataSet.Tables[0].Rows[i][3].ToString(), dataSet.Tables[0].Rows[i][4].ToString());

                hotels.Add(hotel);
            }

            //Create and store room classes
            for (int i = 0; i < dataSet.Tables[1].Rows.Count; i++)
            {
                int    id          = Int32.Parse(dataSet.Tables[1].Rows[i][0].ToString());
                int    hotelid     = Int32.Parse(dataSet.Tables[1].Rows[i][1].ToString());
                float  price       = float.Parse(dataSet.Tables[1].Rows[i][2].ToString());
                string name        = dataSet.Tables[1].Rows[i][3].ToString();
                string description = dataSet.Tables[1].Rows[i][4].ToString();

                List <DateTime> reservedDates = new List <DateTime>();

                //get reserved dates for room
                for (int j = 0; j < dataSet.Tables[2].Rows.Count; j++)
                {
                    if (Int32.Parse(dataSet.Tables[2].Rows[j][1].ToString()) == id)
                    {
                        string start = dataSet.Tables[2].Rows[j][2].ToString();
                        string end   = dataSet.Tables[2].Rows[j][3].ToString();

                        DateTime startingDate = new DateTime(Int32.Parse(start.Substring(6, 4)), Int32.Parse(start.Substring(3, 2)), Int32.Parse(start.Substring(0, 2)));
                        DateTime endingDate   = new DateTime(Int32.Parse(end.Substring(6, 4)), Int32.Parse(end.Substring(3, 2)), Int32.Parse(end.Substring(0, 2)));

                        //generates all dates betweeen start and end
                        for (DateTime date = startingDate; date <= endingDate; date = date.AddDays(1))
                        {
                            reservedDates.Add(date);
                        }
                    }
                }
                //add rooms to appropriate hotel
                hotels.Find(hotel => hotel.Id == hotelid).AddRoom(id, name, description, price, reservedDates);
            }

            //create and store billable item classes
            for (int i = 0; i < dataSet.Tables[5].Rows.Count; i++)
            {
                int          id           = Int32.Parse(dataSet.Tables[5].Rows[i][0].ToString());
                string       name         = dataSet.Tables[5].Rows[i][1].ToString();
                string       description  = dataSet.Tables[5].Rows[i][2].ToString();
                float        price        = float.Parse(dataSet.Tables[5].Rows[i][3].ToString());
                BillableItem billableItem = new BillableItem(id, name, description, price);
                items.Add(billableItem);
            }
            //get largest id and set currentid to one larger.
            for (int i = 0; i < dataSet.Tables[2].Rows.Count; i++)
            {
                int bookingid = Int32.Parse(dataSet.Tables[2].Rows[i][0].ToString());
                if (bookingid >= currentBookingID)
                {
                    currentBookingID = bookingid + 1;
                }
            }
            //get largest id and set currentid to one larger.
            for (int i = 0; i < dataSet.Tables[4].Rows.Count; i++)
            {
                int customerid = Int32.Parse(dataSet.Tables[4].Rows[i][0].ToString());
                if (customerid >= currentCustomerID)
                {
                    currentCustomerID = customerid + 1;
                }
            }
        }