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 ReservationPeople ReservationPeople(DataRow row)
 {
     return new ReservationPeople
     {
         id = (!row.IsNull("peopleid")) ? row.ReadNullableTrimmedString("peopleid") : row.ReadNullableInt("localid").ToString(),
         localid = row.ReadNullableInt("localid"),
         agetype = row.ReadNullableTrimmedString("agetype"),
         gender = row.ReadNullableTrimmedString("gender"),
         name = row.ReadNullableTrimmedString("name"),
         born = row.ReadNullableUnspecifiedDateTime("born"),
         age = row.ReadNullableInt("age"),
         passport = (row.IsNull("pserie") && row.IsNull("pnumber")) ? null : new ReservationPeoplePassport
         {
             serie = row.ReadNullableTrimmedString("pserie"),
             number = row.ReadNullableTrimmedString("pnumber"),
             issue = row.ReadNullableUnspecifiedDateTime("pissue"),
             valid = row.ReadNullableUnspecifiedDateTime("pvalid")
         },
         address = row.ReadNullableTrimmedString("address"),
         phone = row.ReadNullableTrimmedString("phones"),
         email = row.ReadNullableTrimmedString("email"),
         comment = row.ReadNullableTrimmedString("comment")
     };
 }
 public ExternalCartAddOrderResult ExternalCartAddOrderResult(DataRow row)
 {
     return new ExternalCartAddOrderResult
     {
         errorcode = row.ReadInt("error_code"),
         errormessage = row.ReadNullableTrimmedString("error_msg"),
         ordercount = row.ReadNullableInt("ordercount")
     };
 }
            public ReservationCustomer ReservationCustomer(DataRow row)
            {
                return new ReservationCustomer()
                {
                    address = row.ReadNullableTrimmedString("address"),
                    id = row.ReadNullableInt("inc"),
                    name = row.ReadNullableTrimmedString("name"),
                    phone = row.ReadNullableTrimmedString("phones"),
                    mail = row.ReadNullableTrimmedString("email"),

                    language = row.ReadNullableTrimmedString("language"),
                };
            }
 public ReservationState ReservationState(DataRow row)
 {
     return new ReservationState
     {
         claimId = row.ReadNullableInt("claim_id"),
         status = row.IsNull("status_id") ? null : new ReservationStatus
         {
             id = row.ReadInt("status_id"),
             description = row.ReadNullableTrimmedString("status_name")
         },
         partner = row.IsNull("partner_id") ? null : new ReservationPartner
         {
             id = row.ReadInt("partner_id"),
             name = row.ReadNullableTrimmedString("partner_name")
         },
         confirmation = row.IsNull("confirm_id") ? null : new ReservationConfirmStatus
         {
             id = row.ReadInt("confirm_id"),
             description = row.ReadNullableTrimmedString("confirm_name")
         },
         price = (row.IsNull("payprice") || row.IsNull("payrest") || row.IsNull("paycurrency")) ? null : new ReservationPrice
         {
             total = row.ReadDecimal("payprice"),
             topay = row.ReadDecimal("payrest"),
             currency = row.ReadNullableTrimmedString("paycurrency")
         },
         action = new ReservationAction
         {
             canshowprice = row.ReadBoolean("showprice", false),
             canprintvoucher = row.ReadBoolean("printvoucher", false),
             canpay = row.ReadBoolean("canpay", false)
         },
         timelimit = GetClaimTimelimit(row.ReadNullableInt("claim_id"))
     };
 }
 internal GuestOrder GuestOrder(DataRow row)
 {
     GuestOrder result = new GuestOrder();
     result.period = new DatePeriod
     {
         begin = new System.DateTime?(row.ReadDateTime("order$datebeg")),
         end = new System.DateTime?(row.ReadDateTime("order$dateend"))
     };
     if (!row.IsNull("hotel$id"))
     {
         result.hotelid = row.ReadNullableInt("hotel$id");
         result.title = row.ReadNullableTrimmedString("hotel$name");
         result.description = row.ReadNullableTrimmedString("hotel$room");
     }
     else
     {
         if (!row.IsNull("service$id"))
         {
             result.serviceid = row.ReadNullableInt("service$id");
             result.title = row.ReadNullableTrimmedString("service$name");
         }
     }
     return result;
 }
 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")
         }
     };
 }
 internal DepartureMember DepartureMember(bool useNameField, DataRow row)
 {
     return new DepartureMember
     {
         human = row.ReadNullableTrimmedString("transfer$human"),
         name = row.ReadNullableTrimmedString(useNameField ? "people$name" : "people$name"),
         claim = row.ReadNullableInt("people$claim")
     };
 }