Пример #1
0
        public VehicleSubType PostVehicleSubType(object obj)
        {
            VehicleSubType SR = new VehicleSubType();

            WSP_Mst_VehicleSubType_GetList_Result data = obj.GetData <WSP_Mst_VehicleSubType_GetList_Result>();
            string oper = obj.GetOperation();

            List <WSP_Mst_VehicleSubType_GetList_Result> vehicleSubType = new List <WSP_Mst_VehicleSubType_GetList_Result>();

            try
            {
                db.WSP_Mst_VehicleSubType_DML_Oper(data.id, data.vehicleTypeCDE, data.text, data.vehicleSubTypeNameAr, data.active, oper);

                vehicleSubType = db.WSP_Mst_VehicleSubType_GetList().ToList();
                if (vehicleSubType.Count() > 0)
                {
                    SR.status = 1; SR.vehicleSubType = vehicleSubType; SR.message = "Success.!!";
                }
                return(SR);
            }
            catch
            {
                SR.message = "Error Occured "; SR.vehicleSubType = vehicleSubType; SR.status = 0;
                return(SR);
            }
        }
Пример #2
0
        public IEnumerable <double> GetEmissionFactors(GetEmissionRequest data)
        {
            VehicleTypeRepository repo = new VehicleTypeRepository(CONNECTION_STRING);

            Guid           subTypeId      = Guid.Parse(data.VehicleSubTypeId);
            VehicleSubType details        = repo.GetSubTypeDetails(subTypeId);
            double         emissionFactor = details.FuelType.CO2EmissionFactor;
            double         mileage        = details.Mileage;
            //converting the entire leg distance to an array and then performing actions and conveting to an array and then passing this back to client
            List <double> _legDistance = new List <double>();

            for (int i = 0; i < data.Distance.Length; i++)
            {
                _legDistance.Add((data.Distance[i] / mileage) * emissionFactor);
            }
            return(_legDistance);
        }
Пример #3
0
        public VehicleSubType GetVehicleSubType()
        {
            VehicleSubType Res = new VehicleSubType();
            List <WSP_Mst_VehicleSubType_GetList_Result> vehicleSubType = new List <WSP_Mst_VehicleSubType_GetList_Result>();

            try
            {
                vehicleSubType = db.WSP_Mst_VehicleSubType_GetList().ToList();
                if (vehicleSubType.Count() > 0)
                {
                    Res.status = 1; Res.vehicleSubType = vehicleSubType;
                }
                return(Res);
            }
            catch (Exception ex)
            {
                Res.message = "Error Occured in fetching ServiceType(s)"; Res.vehicleSubType = vehicleSubType; Res.status = 0;
                return(Res);
            }
        }
Пример #4
0
        public double[] GetEmission(GetEmissionRequest request)
        {
            VehicleTypeRepository repo = new VehicleTypeRepository(CONNECTION_STRING);

            /*Dictionary<string, object> routeData = new JavaScriptSerializer().Deserialize<Dictionary<string, object>>(routeDetails);
             * Dictionary<string, object> legs = (routeData["routes"] as Dictionary<string, object>)["legs"] as Dictionary<string, object>;
             * ArrayList steps = legs["steps"] as ArrayList;
             * foreach (var step in steps)
             * {
             *  Dictionary<string, object> distanceData = (step as Dictionary<string, object>)["distance"] as Dictionary<string, object>;
             *  decimal distance = Decimal.Parse(distanceData["value"] as string);
             *  Guid subTypeId = Guid.Parse(vehicleSubType);
             *  VehicleSubType details = repo.GetSubTypeDetails(subTypeId);
             *  decimal emissionFactor = details.FuelType.CO2Emissions;
             *  decimal mileage = details.Mileage;
             *  decimal CO2Emissions = emissionFactor * (distance / mileage);
             *  StringBuilder instructions = new StringBuilder((step as Dictionary<string, object>)["instructions"] as string);
             *  instructions.Insert(0, CO2Emissions.ToString());
             *  (step as Dictionary<string, object>)["instructions"] = instructions.ToString();
             * }
             * return (new JavaScriptSerializer()).Serialize(routeData);
             */
            Guid           subTypeId      = Guid.Parse(request.VehicleSubTypeId);
            VehicleSubType details        = repo.GetSubTypeDetails(subTypeId);
            double         emissionFactor = details.FuelType.CO2EmissionFactor;
            double         mileage        = details.Mileage;
            //converting the entire leg distance to an array and then performing actions and conveting to an array and then passing this back to client
            List <double> _legDistance = new List <double>();

            for (int i = 0; i < request.Distance.Length; i++)
            {
                _legDistance.Add((request.Distance[i] / mileage) * emissionFactor);
            }
            return(_legDistance.ToArray());

            //decimal CO2Emissions = emissionFactor * (request.Distance / mileage);
            //return CO2Emissions;
        }