Esempio n. 1
0
        public OfferDetails GetOfferDetails(int accident_id)
        {
            OfferQuery offerQuery = new OfferQuery(language);

            System.Data.DataTable dataTable = conn_db.ReadTable(offerQuery.GetOfferDetailsByOrderId(accident_id));

            OfferDetails offerDetails = new OfferDetails();

            if (dataTable.Rows.Count == 0)
            {
                throw new EmptyViewException(language);
            }


            offerDetails                    = new OfferDetails();
            offerDetails.OFFER_ID           = Convert.ToInt32(dataTable.Rows[0]["OFFER_ID"]);
            offerDetails.shop_ID            = Convert.ToInt32(dataTable.Rows[0]["WORKSHOP_ID"]);
            offerDetails.FULLNAME           = dataTable.Rows[0]["FULLNAME"].ToString();
            offerDetails.SHOPNUMBER         = dataTable.Rows[0]["SHOPNUMBER"].ToString();
            offerDetails.SHOPNAME           = dataTable.Rows[0]["SHOPNAME"].ToString();
            offerDetails.LOCATIONX_WORKSHOP = Convert.ToDouble(dataTable.Rows[0]["LOCATIONX"].ToString());
            offerDetails.LOCATIONY_WORKSHOP = Convert.ToDouble(dataTable.Rows[0]["LOCATIONY"].ToString());
            offerDetails.CONFIRMATION       = Convert.ToInt32(dataTable.Rows[0]["CONFIRMATION"].ToString());
            offerDetails.timeValue          = dataTable.Rows[0]["timeValue"] is DBNull ? 0 : Convert.ToInt32(dataTable.Rows[0]["timeValue"]);
            offerDetails.timeFlag           = dataTable.Rows[0]["timeFlag"] is DBNull ? 0 : Convert.ToInt32(dataTable.Rows[0]["timeFlag"]);
            offerDetails.PRICE              = Convert.ToDouble(dataTable.Rows[0]["PRICE"]);
            offerDetails.rating             = Convert.ToDouble(dataTable.Rows[0]["RATING"]);
            offerDetails.workshop_image     = dataTable.Rows[0]["IMAGE"].ToString();
            try { offerDetails.OFFER_DATETIME = Convert.ToDateTime(dataTable.Rows[0]["OFFER_DATETIME"]).ToString("dd-MM-yyyy"); }
            catch { offerDetails.OFFER_DATETIME = "01-01-2000"; }
            offerDetails.canFinish   = Convert.ToInt32(dataTable.Rows[0]["WAITINGFIX"].ToString());
            offerDetails.isDelivered = Convert.ToInt32(dataTable.Rows[0]["FINISHEDFLAG"].ToString());

            offerDetails.AreaName    = dataTable.Rows[0]["AreaName"].ToString();
            offerDetails.phonenumber = dataTable.Rows[0]["phoneNumber"].ToString();
            return(offerDetails);
        }
Esempio n. 2
0
        public Domain.Entities.Order.OrdersDetails   GetOrderDetails(int user_id, int order_id, double lat, double lng, int offer_id)
        {
            OrderQuery orderQuery = new OrderQuery(language);
            OfferQuery offerQuery = new OfferQuery(language);

            System.Data.DataTable OrderDT = conn_db.ReadTable(orderQuery.GetRequestByOrder_id(order_id, language));
            int orderStatus = 0;

            if (OrderDT.Rows.Count > 0)
            {
                orderStatus = OrderDT.Rows[0]["order_status"] is DBNull ?  0:Convert.ToInt32(OrderDT.Rows[0]["order_status"]);
            }

            System.Data.DataTable OrderDetailsAssign = conn_db.ReadTable(offerQuery.GetOrderDetailsAssigns(order_id));
            System.Data.DataTable OfferDT            = new System.Data.DataTable();

            if (orderStatus == (int)Enums.orderStatus.UNCONFIRMED)
            {
                OfferDT = conn_db.ReadTable(offerQuery.GetOffertempOfferByOffer_id(offer_id));
            }
            else
            {
                OfferDT = conn_db.ReadTable(offerQuery.GetOfferDetailsByOrderId(order_id));
            }

            UserRequestCriteria userRequestCriteria = new UserRequestCriteria();
            OfferDTO            offersDTO           = new OfferDTO();

            if (OrderDT.Rows.Count == 0)
            {
                throw new EmptyViewException(language, Messages.GetMessage(language, TypeM.ACCIDENT, orderM.Order_DATA_NOT_FOUND));
            }



            userRequestCriteria.ORDER_ID = OrderDT.Rows[0]["ORDER_ID"] is DBNull ? 0 : Convert.ToInt32(OrderDT.Rows[0]["ORDER_ID"]);
            userRequestCriteria.USER_ID  = OrderDT.Rows[0]["USER_ID"]  is DBNull ? 0 : Convert.ToInt32(OrderDT.Rows[0]["USER_ID"].ToString());
            try
            {
                userRequestCriteria.ORDERDATE = Convert.ToDateTime(OrderDT.Rows[0]["ORDERDATE"].ToString()).ToString("dd-MM-yyyy");
            }
            catch (Exception ex)
            {
                userRequestCriteria.ORDERDATE = "";
            }
            userRequestCriteria.PLATENUMBER    = OrderDT.Rows[0]["PLATENUMBER"].ToString();
            userRequestCriteria.ORDER_IDENTITY = OrderDT.Rows[0]["ORDER_IDENTITY"].ToString();
            userRequestCriteria.firstName      = OrderDT.Rows[0]["FIRSTNAME"].ToString();
            userRequestCriteria.lastName       = OrderDT.Rows[0]["LASTNAME"].ToString();
            userRequestCriteria.CountryCode    = OrderDT.Rows[0]["COUNTRY_CODE"] is DBNull ? 0 : Convert.ToInt32(OrderDT.Rows[0]["COUNTRY_CODE"].ToString());
            userRequestCriteria.phoneNumber    = OrderDT.Rows[0]["PHONENUMBER"].ToString();
            userRequestCriteria.ORDERTYPE_ID   = OrderDT.Rows[0]["ORDERTYPE_ID"]  is DBNull ? 0 : Convert.ToInt32(OrderDT.Rows[0]["ORDERTYPE_ID"].ToString());
            userRequestCriteria.ORDERTYPE_NAME = OrderDT.Rows[0]["ORDERTYPE_NAME"].ToString();
            userRequestCriteria.VEHICLE_ID     = OrderDT.Rows[0]["VEHICLE_ID"]  is DBNull ? 0 :  Convert.ToInt32(OrderDT.Rows[0]["VEHICLE_ID"].ToString());
            userRequestCriteria.ORDER_STATUS   = OrderDT.Rows[0]["ORDER_STATUS"] is DBNull ? 0 : Convert.ToInt32(OrderDT.Rows[0]["ORDER_STATUS"].ToString());
            userRequestCriteria.ISACTIVE       = OrderDT.Rows[0]["ISACTIVE"] is DBNull ? 0 : Convert.ToInt32(OrderDT.Rows[0]["ISACTIVE"].ToString());
            userRequestCriteria.OFFERS_COUNT   = OrderDT.Rows[0]["OFFERS_COUNT"]  is DBNull ? 0 : Convert.ToInt32(OrderDT.Rows[0]["OFFERS_COUNT"].ToString());
            if (language == Messages.language.ar.ToString())
            {
                userRequestCriteria.BRANDNAME = OrderDT.Rows[0]["BRANDNAME_AR"].ToString();
                userRequestCriteria.MODELNAME = OrderDT.Rows[0]["MODELNAME_AR"].ToString();
            }
            else
            {
                userRequestCriteria.BRANDNAME = OrderDT.Rows[0]["BRANDNAME_EN"].ToString();
                userRequestCriteria.MODELNAME = OrderDT.Rows[0]["MODELNAME_EN"].ToString();
            }
            userRequestCriteria.carIMAGE  = OrderDT.Rows[0]["carImage"].ToString();
            userRequestCriteria.userIMAGE = OrderDT.Rows[0]["userImage"].ToString();
            userRequestCriteria.Note      = OrderDT.Rows[0]["NOTE"].ToString();
            userRequestCriteria.COLORNAME = OrderDT.Rows[0]["COLOR_NAME"].ToString();

            userRequestCriteria.lat = OrderDT.Rows[0]["lat"] is DBNull ? 0 : Convert.ToDouble(OrderDT.Rows[0]["lat"].ToString());
            userRequestCriteria.lng = OrderDT.Rows[0]["lng"] is DBNull ? 0 : Convert.ToDouble(OrderDT.Rows[0]["lng"].ToString());


            if (lat == 0 || lng == 0 || userRequestCriteria.lat == 0 || userRequestCriteria.lng == 0)
            {
                userRequestCriteria.time     = "0";
                userRequestCriteria.distance = 0;
            }
            else
            {
                double distanceMiles1 = Math.Sqrt(
                    Math.Pow((lat - userRequestCriteria.lat) * 69, 2) +
                    Math.Pow((lng - userRequestCriteria.lng) * 69.172, 2));
                userRequestCriteria.distance = Math.Round(distanceMiles1 * 1.60934, 2);
                userRequestCriteria.time     = new ServicesRepository(language).getTime(lat + "," + lng, userRequestCriteria.lat + "," + userRequestCriteria.lng);
            }



            if (OfferDT.Rows.Count > 0)
            {
                offersDTO.OFFER_ID      = OfferDT.Rows[0]["OFFER_ID"] is DBNull ? 0 : Convert.ToInt32(OfferDT.Rows[0]["OFFER_ID"]);
                offersDTO.offerStatus   = OfferDT.Rows[0]["OFFER_STATUS"] is DBNull ? 0: Convert.ToInt32(OfferDT.Rows[0]["OFFER_STATUS"]);
                offersDTO.ORDER_ID      = OfferDT.Rows[0]["ORDER_ID"] is DBNull ? 0 : Convert.ToInt32(OfferDT.Rows[0]["ORDER_ID"]);
                offersDTO.PRICE         = OfferDT.Rows[0]["PRICE"] is DBNull ? 0 : Convert.ToDouble(OfferDT.Rows[0]["PRICE"]);
                offersDTO.SUPPLIER_Name = OfferDT.Rows[0]["SUPPLIER_Name"] is DBNull ? "" : OfferDT.Rows[0]["SUPPLIER_Name"].ToString();
                offersDTO.timeValue     = OfferDT.Rows[0]["timeValue"] is DBNull ? 0 : Convert.ToInt32(OfferDT.Rows[0]["timeValue"]);
                offersDTO.timeFlag      = OfferDT.Rows[0]["timeFlag"] is DBNull ? 0 : Convert.ToInt32(OfferDT.Rows[0]["timeFlag"]);
                offersDTO.supplierImage = OfferDT.Rows[0]["supplierImage"] is DBNull ? "" :  OfferDT.Rows[0]["supplierImage"].ToString();
                offersDTO.CountryCode   = OfferDT.Rows[0]["COUNTRY_CODE"] is DBNull ? 0 : Convert.ToInt32(OfferDT.Rows[0]["COUNTRY_CODE"]);
                offersDTO.PHONENUMBER   = OfferDT.Rows[0]["PHONENUMBER"] is DBNull ? "" : OfferDT.Rows[0]["PHONENUMBER"].ToString();
                offersDTO.lat           = OfferDT.Rows[0]["LOCATIONX"] is DBNull ? 0 : Convert.ToDouble(OfferDT.Rows[0]["LOCATIONX"]);
                offersDTO.lng           = OfferDT.Rows[0]["LOCATIONY"] is DBNull ? 0 : Convert.ToDouble(OfferDT.Rows[0]["LOCATIONY"]);
                offersDTO.Rating        = OfferDT.Rows[0]["RATING"] is DBNull ? 0 : Convert.ToDouble(OfferDT.Rows[0]["RATING"]);

                offersDTO.RateType   = new Enums().checkRateTypeWords(offersDTO.Rating, language);
                offersDTO.RateTypeId = (int)new Enums().checkRateType(offersDTO.Rating);


                if (lat == 0 || lng == 0 || offersDTO.lat == 0 || offersDTO.lng == 0)
                {
                    offersDTO.time     = "0";
                    offersDTO.DISTANCE = 0;
                }
                else
                {
                    double distanceMiles2 = Math.Sqrt(
                        Math.Pow((lat - offersDTO.lat) * 69, 2) +
                        Math.Pow((lng - offersDTO.lng) * 69.172, 2));
                    offersDTO.DISTANCE = Math.Round(distanceMiles2 * 1.60934, 2);
                    offersDTO.time     = new ServicesRepository(language).getTime(lat + "," + lng, offersDTO.lat + "," + offersDTO.lng);
                }
            }
            infoAssign        info;
            List <infoAssign> infoAssigns = new List <infoAssign>();

            if (OrderDetailsAssign.Rows.Count > 0)
            {
                foreach (System.Data.DataRow row in OrderDetailsAssign.Rows)
                {
                    info = new infoAssign();
                    if (language == Messages.language.ar.ToString())
                    {
                        info.key   = row["LISTNAME_AR"].ToString();
                        info.value = row["CONTENTNAME_AR"].ToString();
                    }
                    else
                    {
                        info.key   = row["LISTNAME_EN"].ToString();
                        info.value = row["CONTENTNAME_EN"].ToString();
                    }
                    infoAssigns.Add(info);
                }
            }


            userRequestCriteria.info = infoAssigns;
            Domain.Entities.Order.OrdersDetails orderDatails = new Domain.Entities.Order.OrdersDetails();
            orderDatails.order = userRequestCriteria;
            orderDatails.offer = offersDTO;



            return(orderDatails);
        }