public string ReservationOrderSorting(DataRow row)
 {
     System.DateTime datefrom = row.ReadUnspecifiedDateTime("datefrom");
     datefrom.ToString();
     string text = row.ReadString("type").ToLower();
     string result;
     if (text != null)
     {
         if (text == "hotel")
         {
             result = string.Format("A.{0:s}", datefrom);
             return result;
         }
         if (text == "transport")
         {
             result = string.Format("B.{0:s}", datefrom);
             return result;
         }
         if (text == "transfer")
         {
             result = string.Format("C.{0:s}", datefrom);
             return result;
         }
         if (text == "service")
         {
             result = string.Format("D.{0:s}", datefrom);
             return result;
         }
         if (text == "excursion")
         {
             result = string.Format("E.{0:s}", datefrom);
             return result;
         }
     }
     result = "Z";
     return result;
 }
            public ReservationOrder ReservationOrder(DataRow row, string language, int? claimId, string orderNote)
            {
                ReservationOrder result = new ReservationOrder
                {
                    id = (!row.IsNull("orderid")) ? row.ReadNullableTrimmedString("orderid") : row.ReadNullableInt("localid").ToString(),
                    localid = row.ReadNullableInt("localid"),
                    status = new ReservationStatus
                    {
                        id = row.ReadInt("actstatusid"),
                        description = row.ReadNullableTrimmedString("actstatusname")
                    },
                    datefrom = row.ReadUnspecifiedDateTime("datefrom"),
                    datetill = row.ReadUnspecifiedDateTime("datetill"),
                    partner = row.IsNull("partnerid") ? null : new ReservationPartner
                    {
                        id = row.ReadInt("partnerid"),
                        name = row.ReadNullableTrimmedString("partnername")
                    },
                    pax = new ReservationPax
                    {
                        adult = row.ReadInt("adult"),
                        child = row.ReadInt("child"),
                        infant = row.ReadInt("infant"),
                        extra = row.ReadInt("addinfant")
                    },
                    note = row.ReadNullableTrimmedString("note"),
                    price = (row.IsNull("saleprice") || row.IsNull("salecurrency")) ? null : new ReservationOrderPrice
                    {
                        total = row.ReadDecimal("saleprice"),
                        currency = row.ReadNullableTrimmedString("salecurrency")
                    }
                };
                XElement peopleXml = row.ReadXml("peoples");
                if (peopleXml != null)
                {
                    result.peopleids = new System.Collections.Generic.List<string>();
                    foreach (XElement peopleNode in peopleXml.DescendantsAndSelf("People"))
                    {
                        XElement idNode = peopleNode.Element("Id");
                        XElement localidNode = peopleNode.Element("LocalId");
                        result.peopleids.Add((idNode != null) ? idNode.Value : ((localidNode != null) ? localidNode.Value : ""));
                    }
                }
                string orderType = row.ReadString("type").ToLower();
                if (orderType == "hotel")
                {
                    result.hotel = new HotelReservationOrder
                    {
                        id = row.ReadInt("hotelid"),
                        name = row.ReadNullableTrimmedString("hotelname"),
                        room = row.IsNull("roomid") ? null : new HotelReservationRoom
                        {
                            id = row.ReadInt("roomid"),
                            name = row.ReadNullableTrimmedString("roomname")
                        },
                        htplace = row.IsNull("htplaceid") ? null : new HotelReservationHtplace
                        {
                            id = row.ReadInt("htplaceid"),
                            name = row.ReadNullableTrimmedString("htplacename")
                        },
                        meal = row.IsNull("mealid") ? null : new HotelReservationMeal
                        {
                            id = row.ReadInt("mealid"),
                            name = row.ReadNullableTrimmedString("mealname")
                        }
                    };
                }
                else
                {
                    if (orderType == "excursion")
                    {
                        result.excursion = new ExcursionReservationOrder
                        {
                            id = row.ReadInt("excursid"),
                            name = row.ReadNullableTrimmedString("excursname"),
                            time = row.IsNull("extimeid") ? null : new ExcursionReservationTime
                            {
                                id = row.ReadInt("extimeid"),
                                description = row.ReadNullableTrimmedString("extimename")
                            },
                            grouptype = row.IsNull("exgrouptypeid") ? null : new ExcursionReservationGroup
                            {
                                id = row.ReadInt("exgrouptypeid"),
                                description = row.ReadNullableTrimmedString("exgrouptypename")
                            },
                            language = row.IsNull("languageid") ? null : new ExcursionReservationLanguage
                            {
                                id = row.ReadInt("languageid"),
                                description = row.ReadNullableTrimmedString("languagename")
                            },
                            pickuppoint = row.IsNull("geopointfromid") ? null : new PickupPlace
                            {
                                id = row.ReadInt("geopointfromid"),
                                name = row.ReadNullableTrimmedString("geopointfromname")
                            },
                            pickuphotel = row.IsNull("fromhotelid") ? null : new PickupPlace
                            {
                                id = row.ReadInt("fromhotelid"),
                                name = row.ReadNullableTrimmedString("fromhotelname")
                            },

                            included = GetExcursionIncluded(row.ReadInt("excursid"), language),

                            pickup = GetExcursionPickup(row.ReadInt("excursid"), language, claimId, orderNote)
                        };
                    }
                    else
                    {
                        if (orderType == "transport")
                        {
                            result.freight = new FreightReservationOrder
                            {
                                id = row.ReadInt("freightid"),
                                name = row.ReadNullableTrimmedString("freightname"),
                                bookingclass = row.IsNull("classid") ? null : new FreightReservationBookingclass
                                {
                                    id = row.ReadInt("classid"),
                                    name = row.ReadNullableTrimmedString("classname")
                                },
                                place = row.IsNull("frplaceid") ? null : new FreightReservationPlace
                                {
                                    id = row.ReadInt("frplaceid"),
                                    name = row.ReadNullableTrimmedString("frplacename")
                                }
                            };
                        }
                        else
                        {
                            if (orderType == "transfer")
                            {
                                result.transfer = new TransferReservationOrder
                                {
                                    id = row.ReadInt("serviceid"),
                                    name = row.ReadNullableTrimmedString("servicename")
                                };
                            }
                            else
                            {
                                if (orderType == "service")
                                {
                                    result.service = new ServiceReservationOrder
                                    {
                                        id = row.ReadInt("serviceid"),
                                        name = row.ReadNullableTrimmedString("servicename"),
                                        servicetype = row.IsNull("servtypeid") ? null : new ServiceReservationServicetype
                                        {
                                            id = row.ReadInt("servtypeid"),
                                            name = row.ReadNullableTrimmedString("servtypename")
                                        }
                                    };
                                }
                            }
                        }
                    }
                }
                return result;
            }
 public void FillFreightInfo(FreightReservationOrder freight, DataRow row)
 {
     if (row != null)
     {
         System.TimeSpan? freightDepartureTime = row.ReadNullableUnspecifiedTime("stime");
         FreightPoint freightPoint = new FreightPoint();
         FreightPoint arg_5C_0 = freightPoint;
         System.DateTime dateTime = row.ReadUnspecifiedDateTime("sdate");
         dateTime = dateTime.Date;
         arg_5C_0.date = dateTime.Add(freightDepartureTime ?? System.TimeSpan.FromTicks(0L));
         freightPoint.port = new Airport
         {
             id = row.ReadInt("sport$inc"),
             alias = row.ReadNullableTrimmedString("sport$alias"),
             name = row.ReadNullableTrimmedString("sport$name"),
             town = new Town
             {
                 id = row.ReadInt("stown$inc"),
                 name = row.ReadNullableString("stown$name")
             }
         };
         freight.departure = freightPoint;
         System.TimeSpan? freightArrivalTime = row.ReadNullableUnspecifiedTime("dtime");
         FreightPoint freightPoint2 = new FreightPoint();
         FreightPoint arg_147_0 = freightPoint2;
         dateTime = freight.departure.date;
         dateTime = dateTime.Date;
         dateTime = dateTime.AddDays((double)row.ReadInt("daysinway"));
         arg_147_0.date = dateTime.Add(freightArrivalTime ?? System.TimeSpan.FromTicks(0L));
         freightPoint2.port = new Airport
         {
             id = row.ReadInt("dport$inc"),
             alias = row.ReadNullableTrimmedString("dport$alias"),
             name = row.ReadNullableTrimmedString("dport$name"),
             town = new Town
             {
                 id = row.ReadInt("dtown$inc"),
                 name = row.ReadNullableString("dtown$name")
             }
         };
         freight.arrival = freightPoint2;
     }
 }
 public ExcursionOrderCalculatePrice ExcursionOrderCalculatePrice(DataRow row)
 {
     return new ExcursionOrderCalculatePrice
     {
         id = row.ReadInt("excursion$inc"),
         name = row.ReadNullableTrimmedString("excursion$name"),
         date = row.ReadUnspecifiedDateTime("date"),
         time = row.IsNull("time$inc") ? null : new ExcursionTime
         {
             id = row.ReadInt("time$inc"),
             name = row.ReadNullableTrimmedString("time$name")
         },
         language = row.IsNull("lang$inc") ? null : new Language
         {
             id = row.ReadInt("lang$inc"),
             name = row.ReadNullableTrimmedString("lang$name"),
             alias = row.ReadNullableTrimmedString("lang$alias")
         },
         group = row.IsNull("group$inc") ? null : new ExcursionGroup
         {
             id = row.ReadInt("group$inc"),
             name = row.ReadNullableTrimmedString("group$name")
         },
         departure = row.IsNull("departure$inc") ? null : new GeoArea
         {
             id = row.ReadInt("departure$inc"),
             name = row.ReadNullableTrimmedString("departure$name"),
             alias = row.ReadNullableTrimmedString("departure$alias")
         },
         pax = new BookingPax
         {
             adult = row.ReadInt("adult", 0),
             child = row.ReadInt("child", 0),
             infant = row.ReadInt("infant", 0)
         },
         contact = new ExcursionContact
         {
             name = row.ReadNullableTrimmedString("contact$name")
         },
         note = row.ReadNullableTrimmedString("note"),
         price = row.IsNull("price") ? null : new OrderPrice
         {
             price = row.ReadDecimal("price"),
             currency = row.ReadNullableTrimmedString("currency$alias")
         },
         closesaletime = row.ReadNullableUnspecifiedDateTime("closesaletime"),
         issaleclosed = row.ReadBoolean("isclosed"),
         isstopsale = row.ReadBoolean("isstopsale")
     };
 }
 internal ExcursionTransfer ExcursionTransfer(DataRow row)
 {
     return new ExcursionTransfer
     {
         claim = row.ReadNullableInt("claim"),
         order = row.ReadNullableInt("order"),
         exsale = row.ReadNullableInt("exsale"),
         voucher = row.ReadNullableTrimmedString("voucher"),
         excursion = row.ReadNullableTrimmedString("excurs$name"),
         excursiontime = row.ReadNullableTrimmedString("excurs$time"),
         transferident = row.ReadNullableTrimmedString("transfer$ident"),
         transfernote = row.ReadNullableTrimmedString("transfer$note"),
         date = row.ReadUnspecifiedDateTime("date"),
         pickup = (!row.IsNull("picktime")) ? new System.DateTime?(row.ReadUnspecifiedDateTime("date").Date.Add(row.ReadUnspecifiedTime("picktime"))) : null,
         pickupplace = row.ReadNullableTrimmedString("pickup$name"),
         guide = (!row.IsNull("guide$name")) ? new DepartureWorker
         {
             name = row.ReadNullableTrimmedString("guide$name"),
             phone = row.ReadNullableTrimmedString("guide$mobile")
         } : null,
         guide2 = (!row.IsNull("guide2$name")) ? new DepartureWorker
         {
             name = row.ReadNullableTrimmedString("guide2$name"),
             phone = row.ReadNullableTrimmedString("guide2$mobile")
         } : null
     };
 }
 internal DepartureTransfer DepartureTransfer(bool useNameField, DataRow row)
 {
     return new DepartureTransfer
     {
         id = row.ReadInt("transfer$inc"),
         ident = row.ReadNullableTrimmedString("transfer$ident"),
         date = row.ReadUnspecifiedDateTime("transfer$tdate"),
         pickup = (row.IsNull("transfer$pickdate") || row.IsNull("transfer$picktime")) ? null : new System.DateTime?(row.ReadUnspecifiedDateTime("transfer$pickdate").Date.Add(row.ReadUnspecifiedDateTime("transfer$picktime").TimeOfDay)),
         flight = (!(row.ReadNullableInt("transfer$freight") > 0)) ? null : new DepartureFlight
         {
             id = row.ReadInt("transfer$freight"),
             name = row.ReadNullableTrimmedString(useNameField ? "f$name" : "f$lname"),
             source = (!(row.ReadNullableInt("f$srcport") > 0)) ? null : new Airport
             {
                 id = row.ReadInt("f$srcport"),
                 alias = row.ReadNullableTrimmedString("port1$alias"),
                 name = row.ReadNullableTrimmedString(useNameField ? "port1$name" : "port1$lname"),
                 town = (!(row.ReadNullableInt("st$inc") > 0)) ? null : new Town
                 {
                     id = row.ReadInt("st$inc"),
                     name = row.ReadNullableTrimmedString("st$name")
                 }
             },
             target = (!(row.ReadNullableInt("f$trgport") > 0)) ? null : new Airport
             {
                 id = row.ReadInt("f$trgport"),
                 alias = row.ReadNullableTrimmedString("port2$alias"),
                 name = row.ReadNullableTrimmedString(useNameField ? "port2$name" : "port2$lname"),
                 town = (!(row.ReadNullableInt("tt$inc") > 0)) ? null : new Town
                 {
                     id = row.ReadInt("tt$inc"),
                     name = row.ReadNullableTrimmedString(useNameField ? "tt$name" : "tt$lname")
                 }
             },
             takeoff = (row.IsNull("transfer$fdate") || row.IsNull("f$srctime")) ? null : new System.DateTime?(row.ReadUnspecifiedDateTime("transfer$fdate").Date.Add(row.ReadUnspecifiedDateTime("f$srctime").TimeOfDay)),
             landingtime = row.IsNull("f$trgtime") ? null : new System.TimeSpan?(row.ReadUnspecifiedDateTime("f$trgtime").TimeOfDay)
         },
         hotel = (!(row.ReadNullableInt("transfer$hoteldest") > 0)) ? null : new DepartureDestinationHotel
         {
             id = row.ReadInt("transfer$hoteldest"),
             name = row.ReadNullableTrimmedString(useNameField ? "h2$name" : "h2$lname"),
             town = (!(row.ReadNullableInt("t2$inc") > 0)) ? null : new Town
             {
                 id = row.ReadInt("t2$inc"),
                 name = row.ReadNullableTrimmedString(useNameField ? "t2$name" : "t2$lname")
             },
             region = (!(row.ReadNullableInt("r2$inc") > 0)) ? null : new Region
             {
                 id = row.ReadInt("r2$inc"),
                 name = row.ReadNullableTrimmedString(useNameField ? "r2$name" : "r2$lname")
             }
         },
         note = row.ReadNullableTrimmedString("transfer$infonote"),
         language = row.ReadNullableTrimmedString("language$alias"),
         indiviadual = row.ReadNullableTrimmedString("transfer$indmark") == "IND",
         servicename = row.ReadNullableTrimmedString(useNameField ? "s$name" : "s$lname"),
         guide = (!(row.ReadNullableInt("transfer$guide") > 0)) ? null : new DepartureWorker
         {
             name = row.ReadNullableTrimmedString(useNameField ? "guide$name" : "guide$lname"),
             phone = row.ReadNullableTrimmedString("guide$mobile")
         },
         guide2 = (!(row.ReadNullableInt("transfer$guide2") > 0)) ? null : new DepartureWorker
         {
             name = row.ReadNullableTrimmedString(useNameField ? "guide2$name" : "guide2$lname"),
             phone = row.ReadNullableTrimmedString("guide2$mobile")
         }
     };
 }