فهرست منبع

simplify code

Robert 1 سال پیش
والد
کامیت
fb0f135236
1فایلهای تغییر یافته به همراه5 افزوده شده و 34 حذف شده
  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;
                                 }
                             }