Explorar el Código

simplify code

Robert hace 1 año
padre
commit
fb0f135236
Se han modificado 1 ficheros con 5 adiciones y 34 borrados
  1. 5 34
      EVCB_OCPP.WSServer/Message/CoreProfileHandler.cs

+ 5 - 34
EVCB_OCPP.WSServer/Message/CoreProfileHandler.cs

@@ -521,19 +521,8 @@ internal partial class ProfileHandler
                                 var price = authorization_result.ChargePointFee.Where(x => x.IsAC == session.IsAC).First();
                                 if (price != null)
                                 {
-
-                                    if (session.UserPrices.ContainsKey(_request.idTag))
-                                    {
-                                        session.UserPrices[_request.idTag] = price.PerkWhFee.HasValue ? JsonConvert.SerializeObject(new List<ChargingPrice>() { new ChargingPrice() { StartTime = "00:00", EndTime = "23:59", Fee = price.PerkWhFee.Value } }) : price.PerHourFee.Value.ToString();
-                                        session.UserPrices[_request.idTag] += "|+" + authorization_result.AccountBalance + "+" + "&" + price.ParkingFee + "&|" + price.Currency;
-
-                                    }
-                                    else
-                                    {
-                                        session.UserPrices.Add(_request.idTag, price.PerkWhFee.HasValue ? JsonConvert.SerializeObject(new List<ChargingPrice>() { new ChargingPrice() { StartTime = "00:00", EndTime = "23:59", Fee = price.PerkWhFee.Value } }) : price.PerHourFee.Value.ToString());
-                                        session.UserPrices[_request.idTag] += "|+" + authorization_result.AccountBalance + "+" + "&" + price.ParkingFee + "&|" + price.Currency;
-
-                                    }
+                                    session.UserPrices[_request.idTag] = price.PerkWhFee.HasValue ? JsonConvert.SerializeObject(new List<ChargingPrice>() { new ChargingPrice() { StartTime = "00:00", EndTime = "23:59", Fee = price.PerkWhFee.Value } }) : price.PerHourFee.Value.ToString();
+                                    session.UserPrices[_request.idTag] += "|+" + authorization_result.AccountBalance + "+" + "&" + price.ParkingFee + "&|" + price.Currency;
                                 }
                             }
 
@@ -872,28 +861,10 @@ internal partial class ProfileHandler
                                 var price = authorization_result.ChargePointFee.Where(x => x.IsAC == session.IsAC).First();
                                 if (price != null)
                                 {
+                                    session.UserPrices[_request.idTag] = price.PerkWhFee.HasValue ? JsonConvert.SerializeObject(new List<ChargingPrice>() { new ChargingPrice() { StartTime = "00:00", EndTime = "23:59", Fee = price.PerkWhFee.Value } }) : price.PerHourFee.Value.ToString();
+                                    session.UserPrices[_request.idTag] += "|+" + authorization_result.AccountBalance + "+" + "&" + price.ParkingFee + "&|" + price.Currency;
 
-                                    if (session.UserPrices.ContainsKey(_request.idTag))
-                                    {
-                                        session.UserPrices[_request.idTag] = price.PerkWhFee.HasValue ? JsonConvert.SerializeObject(new List<ChargingPrice>() { new ChargingPrice() { StartTime = "00:00", EndTime = "23:59", Fee = price.PerkWhFee.Value } }) : price.PerHourFee.Value.ToString();
-                                        session.UserPrices[_request.idTag] += "|+" + authorization_result.AccountBalance + "+" + "&" + price.ParkingFee + "&|" + price.Currency;
-
-                                    }
-                                    else
-                                    {
-                                        session.UserPrices.Add(_request.idTag, price.PerkWhFee.HasValue ? JsonConvert.SerializeObject(new List<ChargingPrice>() { new ChargingPrice() { StartTime = "00:00", EndTime = "23:59", Fee = price.PerkWhFee.Value } }) : price.PerHourFee.Value.ToString());
-                                        session.UserPrices[_request.idTag] += "|+" + authorization_result.AccountBalance + "+" + "&" + price.ParkingFee + "&|" + price.Currency;
-
-                                    }
-
-                                    if (session.UserDisplayPrices.ContainsKey(_request.idTag))
-                                    {
-                                        session.UserDisplayPrices[_request.idTag] = price.DisplayMessage;
-                                    }
-                                    else
-                                    {
-                                        session.UserDisplayPrices.Add(_request.idTag, price.DisplayMessage);
-                                    }
+                                    session.UserDisplayPrices[_request.idTag] = price.DisplayMessage;
                                 }
                             }