ApiController - Refactoring abit

This commit is contained in:
DucDangAnh 2020-06-29 10:07:59 +07:00
parent 7b05cbafa2
commit 57101b4d8f

View File

@ -39,7 +39,7 @@ namespace AIParkingApplication
}
catch (Exception ex)
{
Console.WriteLine($"SendEngineRequest : {ex.Message}");
Console.WriteLine($"Login Exception:\t{DateTime.Now.ToString(AppConstant.DATETIME_FORMAT)} \t {ex.Message}");
return new LoginDataModel
{
IsLoginSuccess = false
@ -53,21 +53,22 @@ namespace AIParkingApplication
{
HttpResponseMessage response = await httpClient.GetAsync("/api/statistics");
response.EnsureSuccessStatusCode();
Statistic.ParkInfo parkInfo = await response.Content.ReadAsAsync<Statistic.ParkInfo>();
Statistic.ParkInfo parkingInfo = await response.Content.ReadAsAsync<Statistic.ParkInfo>();
if (string.IsNullOrEmpty(parkInfo.TotalIn))
if (string.IsNullOrEmpty(parkingInfo.TotalIn))
{
parkInfo.TotalIn = "0";
parkingInfo.TotalIn = "0";
}
if (string.IsNullOrEmpty(parkInfo.TotalOut))
if (string.IsNullOrEmpty(parkingInfo.TotalOut))
{
parkInfo.TotalOut = "0";
parkingInfo.TotalOut = "0";
}
return parkInfo;
return parkingInfo;
}
catch (Exception ex)
{
Console.WriteLine($"SendApiStatisticRequest : {ex.Message}");
Console.WriteLine($"GetStatisticInfo Exception:\t{DateTime.Now.ToString(AppConstant.DATETIME_FORMAT)} \t {ex.Message}");
return new Statistic.ParkInfo();
}
}
@ -87,7 +88,7 @@ namespace AIParkingApplication
}
catch (Exception ex)
{
Console.WriteLine($"SendCheckCardRequest : {ex.Message}");
Console.WriteLine($"CheckCard Exception:\t{DateTime.Now.ToString(AppConstant.DATETIME_FORMAT)} \t {ex.Message}");
return new CardValidation();
}
}
@ -123,7 +124,7 @@ namespace AIParkingApplication
}
catch (Exception ex)
{
Console.WriteLine($"SendSaveLogRequest : {ex.Message}");
Console.WriteLine($"SaveLog Exception:\t{DateTime.Now.ToString(AppConstant.DATETIME_FORMAT)} \t {ex.Message}");
return new SaveLogRespone();
}
}
@ -137,7 +138,8 @@ namespace AIParkingApplication
}
}
}
#region Check card validation API
#region Check card validation API Data Model
public class CardModel
{
[JsonProperty("card")]
@ -190,8 +192,7 @@ namespace AIParkingApplication
}
#endregion
#region Save Log API
#region Save Log API Data Model
public class SaveLogRespone
{
[JsonProperty("status")]
@ -241,8 +242,7 @@ namespace AIParkingApplication
}
#endregion
#region Get Config API
#region Get Config API Data Model
public class LoginModel
{
[JsonProperty("username")]
@ -310,8 +310,6 @@ namespace AIParkingApplication
[JsonProperty("laneConfig")]
public LaneConfig LaneConfigData { get; set; }
}
#region API Path
@ -331,7 +329,6 @@ namespace AIParkingApplication
[JsonProperty("apiUpdateLogs")]
public APIProperties ApiUpdateLogs { get; set; }
}
public class APIProperties
@ -351,54 +348,73 @@ namespace AIParkingApplication
{
[JsonProperty("id")]
public int Id { get; set; }
[JsonProperty("gate")]
public int Gate { get; set; }
[JsonProperty("name")]
public string Name { get; set; }
[JsonProperty("type")]
public string Type { get; set; }
[JsonProperty("stream_url")]
public string Stream_url { get; set; }
[JsonProperty("minWidth")]
public double MinWidth { get; set; }
[JsonProperty("maxWidth")]
public double MaxWidth { get; set; }
[JsonProperty("minHeight")]
public double MinHeight { get; set; }
[JsonProperty("maxHeight")]
public double MaxHeight { get; set; }
[JsonProperty("scaleFactor")]
public double ScaleFactor { get; set; }
[JsonProperty("minNeighbors")]
public double MinNeighbors { get; set; }
[JsonProperty("status")]
public double Status { get; set; }
[JsonProperty("isRecognizeCamera")]
public bool IsRecognizeCamera { get; set; }
[JsonProperty("isLongPlate")]
public bool IsLongPlate { get; set; }
[JsonProperty("stt")]
public int Stt { get; set; }
[JsonProperty("roi_config")]
public string Roi_config { get; set; }
[JsonProperty("created_at")]
public int Created_at { get; set; }
[JsonProperty("modified_at")]
public int Modified_at { get; set; }
}
public class Statistics
{
[JsonProperty("moto")]
public string Moto { get; set; }
[JsonProperty("oto")]
public string Oto { get; set; }
[JsonProperty("vip")]
public string Vip { get; set; }
[JsonProperty("total_in")]
public string Total_in { get; set; }
[JsonProperty("total_out")]
public string Total_out { get; set; }
}
@ -476,6 +492,7 @@ namespace AIParkingApplication
public bool IsLongPlate { get; set; }
}
#endregion
#endregion
}