Skip to content

Commit

Permalink
#78 Refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkusMeyer13 committed Feb 24, 2020
1 parent 60f0370 commit 5d301ea
Show file tree
Hide file tree
Showing 6 changed files with 199 additions and 66 deletions.
6 changes: 3 additions & 3 deletions PlanB.Butler.Services/PlanB.Butler.Services/FinanceService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ public static void PostDocumentMoney(
}
catch (Exception e)
{
trace.Add(string.Format("{0} - {1}", MethodBase.GetCurrentMethod().Name, "rejected"), e.Message);
trace.Add(string.Format("{0} - {1} - StackTrace", MethodBase.GetCurrentMethod().Name, "rejected"), e.StackTrace);
trace.Add(string.Format("{0} - {1}", methodName, "rejected"), e.Message);
trace.Add(string.Format("{0} - {1} - StackTrace", methodName, "rejected"), e.StackTrace);
trace.Add("MessageId", messageHeader.MessageId);
trace.Add("DeliveryCount", messageHeader.SystemProperties.DeliveryCount.ToString());
if (messageHeader.SystemProperties.DeliveryCount == 1)
Expand All @@ -125,7 +125,7 @@ public static void PostDocumentMoney(
}
finally
{
log.LogTrace(eventId, $"'{methodName}' - busobjkey finished");
log.LogTrace(eventId, $"'{methodName}' - finished");
log.LogInformation(correlationId, $"'{methodName}' - {messageHeader.SystemProperties.DeliveryCount} - finished", trace);
}
}
Expand Down
22 changes: 12 additions & 10 deletions PlanB.Butler.Services/PlanB.Butler.Services/MealService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Net.Mime;
using System.Reflection;
using System.Threading.Tasks;

Expand Down Expand Up @@ -48,6 +49,7 @@ public static class MealService
/// IActionResult.
/// </returns>
[FunctionName("CreateMeal")]
[Consumes(MediaTypeNames.Application.Json)]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(typeof(ErrorModel), StatusCodes.Status400BadRequest)]
public static async Task<IActionResult> CreateMeal(
Expand Down Expand Up @@ -94,13 +96,13 @@ public static async Task<IActionResult> CreateMeal(
Task task = blob.UploadTextAsync(requestBody);
}

log.LogInformation(correlationId, $"'{methodName}' - success", trace);
actionResult = new OkResult();
log.LogInformation(correlationId, $"'{methodName}' - success", trace);
}
catch (Exception e)
{
trace.Add(string.Format("{0} - {1}", MethodBase.GetCurrentMethod().Name, "rejected"), e.Message);
trace.Add(string.Format("{0} - {1} - StackTrace", MethodBase.GetCurrentMethod().Name, "rejected"), e.StackTrace);
trace.Add(string.Format("{0} - {1}", methodName, "rejected"), e.Message);
trace.Add(string.Format("{0} - {1} - StackTrace", methodName, "rejected"), e.StackTrace);
log.LogInformation(correlationId, $"'{methodName}' - rejected", trace);
log.LogError(correlationId, $"'{methodName}' - rejected", trace);
ErrorModel errorModel = new ErrorModel()
Expand All @@ -115,7 +117,7 @@ public static async Task<IActionResult> CreateMeal(
}
finally
{
log.LogTrace(eventId, $"'{methodName}' - busobjkey finished");
log.LogTrace(eventId, $"'{methodName}' - finished");
log.LogInformation(correlationId, $"'{methodName}' - finished", trace);
}

Expand Down Expand Up @@ -220,8 +222,8 @@ public static async Task<IActionResult> GetMeals(
}
catch (Exception e)
{
trace.Add(string.Format("{0} - {1}", MethodBase.GetCurrentMethod().Name, "rejected"), e.Message);
trace.Add(string.Format("{0} - {1} - StackTrace", MethodBase.GetCurrentMethod().Name, "rejected"), e.StackTrace);
trace.Add(string.Format("{0} - {1}", methodName, "rejected"), e.Message);
trace.Add(string.Format("{0} - {1} - StackTrace", methodName, "rejected"), e.StackTrace);
log.LogInformation(correlationId, $"'{methodName}' - rejected", trace);
log.LogError(correlationId, $"'{methodName}' - rejected", trace);

Expand All @@ -231,11 +233,11 @@ public static async Task<IActionResult> GetMeals(
Details = e.StackTrace,
Message = e.Message,
};
actionResult = new BadRequestObjectResult(meals);
actionResult = new BadRequestObjectResult(errorModel);
}
finally
{
log.LogTrace(eventId, $"'{methodName}' - busobjkey finished");
log.LogTrace(eventId, $"'{methodName}' - finished");
log.LogInformation(correlationId, $"'{methodName}' - finished", trace);
}

Expand Down Expand Up @@ -282,8 +284,8 @@ public static IActionResult GetMealById(
}
catch (Exception e)
{
trace.Add(string.Format("{0} - {1}", MethodBase.GetCurrentMethod().Name, "rejected"), e.Message);
trace.Add(string.Format("{0} - {1} - StackTrace", MethodBase.GetCurrentMethod().Name, "rejected"), e.StackTrace);
trace.Add(string.Format("{0} - {1}", methodName, "rejected"), e.Message);
trace.Add(string.Format("{0} - {1} - StackTrace", methodName, "rejected"), e.StackTrace);
log.LogInformation(correlationId, $"'{methodName}' - rejected", trace);
log.LogError(correlationId, $"'{methodName}' - rejected", trace);

Expand Down
85 changes: 85 additions & 0 deletions PlanB.Butler.Services/PlanB.Butler.Services/Models/OrderModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
// Copyright (c) PlanB. GmbH. All Rights Reserved.
// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.

using System;

namespace PlanB.Butler.Services.Models
{
/// <summary>
/// OrderModel.
/// </summary>
public class OrderModel
{
/// <summary>
/// Gets or sets the date.
/// </summary>
/// <value>
/// The date.
/// </value>
public DateTime Date { get; set; }

/// <summary>
/// Gets or sets the company status.
/// </summary>
/// <value>
/// The company status.
/// </value>
public string CompanyStatus { get; set; }

/// <summary>
/// Gets or sets the name.
/// </summary>
/// <value>
/// The name.
/// </value>
public string Name { get; set; }

/// <summary>
/// Gets or sets the name of the company.
/// </summary>
/// <value>
/// The name of the company.
/// </value>
public string CompanyName { get; set; }

/// <summary>
/// Gets or sets the restaurant.
/// </summary>
/// <value>
/// The restaurant.
/// </value>
public string Restaurant { get; set; }

/// <summary>
/// Gets or sets the meal.
/// </summary>
/// <value>
/// The meal.
/// </value>
public string Meal { get; set; }

/// <summary>
/// Gets or sets the price.
/// </summary>
/// <value>
/// The price.
/// </value>
public double Price { get; set; }

/// <summary>
/// Gets or sets the quantity.
/// </summary>
/// <value>
/// The quantity.
/// </value>
public int Quantity { get; set; }

/// <summary>
/// Gets or sets the total.
/// </summary>
/// <value>
/// The total.
/// </value>
public double Total { get; set; }
}
}
40 changes: 40 additions & 0 deletions PlanB.Butler.Services/PlanB.Butler.Services/Models/OrdersModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// Copyright (c) PlanB. GmbH. All Rights Reserved.
// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.

using System;
using System.Collections.Generic;
using System.Text;

namespace PlanB.Butler.Services.Models
{
/// <summary>
/// OrdersModel.
/// </summary>
public class OrdersModel
{
/// <summary>
/// Gets or sets the date.
/// </summary>
/// <value>
/// The date.
/// </value>
public DateTime Date { get; set; }

/// <summary>
/// Gets or sets the name of the login.
/// </summary>
/// <example>[email protected].</example>
/// <value>
/// The name of the login.
/// </value>
public string LoginName { get; set; }

/// <summary>
/// Gets or sets the orders.
/// </summary>
/// <value>
/// The orders.
/// </value>
public List<OrderModel> Orders { get; set; }
}
}
Loading

0 comments on commit 5d301ea

Please sign in to comment.