Swamy/remove unused using and refactoring entity classes (#1371)

* Removed Unused Usings

* Code Refactoring for readbility. Added spaces and moved the classes to separate file
This commit is contained in:
Viswanatha Swamy 2020-08-04 16:26:29 +05:30 committed by GitHub
parent 17e838263f
commit 736320b920
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
37 changed files with 214 additions and 151 deletions

View File

@ -1,7 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Collections.Generic;
namespace Microsoft.eShopOnContainers.Mobile.Shopping.HttpAggregator.Config
{
@ -10,12 +7,14 @@ namespace Microsoft.eShopOnContainers.Mobile.Shopping.HttpAggregator.Config
public class CatalogOperations
{
public static string GetItemById(int id) => $"/api/v1/catalog/items/{id}";
public static string GetItemsById(IEnumerable<int> ids) => $"/api/v1/catalog/items?ids={string.Join(',', ids)}";
}
public class BasketOperations
{
public static string GetItemById(string id) => $"/api/v1/basket/{id}";
public static string UpdateBasket() => "/api/v1/basket";
}
@ -25,10 +24,15 @@ namespace Microsoft.eShopOnContainers.Mobile.Shopping.HttpAggregator.Config
}
public string Basket { get; set; }
public string Catalog { get; set; }
public string Orders { get; set; }
public string GrpcBasket { get; set; }
public string GrpcCatalog { get; set; }
public string GrpcOrdering { get; set; }
}
}

View File

@ -1,8 +1,4 @@
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace Microsoft.eShopOnContainers.Mobile.Shopping.HttpAggregator.Controllers
{

View File

@ -1,10 +1,11 @@
namespace Microsoft.eShopOnContainers.Mobile.Shopping.HttpAggregator.Filters
using Microsoft.AspNetCore.Authorization;
using Microsoft.OpenApi.Models;
using Swashbuckle.AspNetCore.SwaggerGen;
using System.Collections.Generic;
using System.Linq;
namespace Microsoft.eShopOnContainers.Mobile.Shopping.HttpAggregator.Filters
{
using Microsoft.AspNetCore.Authorization;
using Microsoft.OpenApi.Models;
using Swashbuckle.AspNetCore.SwaggerGen;
using System.Collections.Generic;
using System.Linq;
namespace Basket.API.Infrastructure.Filters
{

View File

@ -1,13 +1,9 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace Microsoft.eShopOnContainers.Mobile.Shopping.HttpAggregator.Models
namespace Microsoft.eShopOnContainers.Mobile.Shopping.HttpAggregator.Models
{
public class AddBasketItemRequest
{
public int CatalogItemId { get; set; }
public string BasketId { get; set; }
public int Quantity { get; set; }

View File

@ -2,6 +2,7 @@
namespace Microsoft.eShopOnContainers.Mobile.Shopping.HttpAggregator.Models
{
public class BasketData
{
public string BuyerId { get; set; }
@ -10,7 +11,6 @@ namespace Microsoft.eShopOnContainers.Mobile.Shopping.HttpAggregator.Models
public BasketData()
{
}
public BasketData(string buyerId)
@ -19,15 +19,4 @@ namespace Microsoft.eShopOnContainers.Mobile.Shopping.HttpAggregator.Models
}
}
public class BasketDataItem
{
public string Id { get; set; }
public int ProductId { get; set; }
public string ProductName { get; set; }
public decimal UnitPrice { get; set; }
public decimal OldUnitPrice { get; set; }
public int Quantity { get; set; }
public string PictureUrl { get; set; }
}
}

View File

@ -0,0 +1,21 @@
namespace Microsoft.eShopOnContainers.Mobile.Shopping.HttpAggregator.Models
{
public class BasketDataItem
{
public string Id { get; set; }
public int ProductId { get; set; }
public string ProductName { get; set; }
public decimal UnitPrice { get; set; }
public decimal OldUnitPrice { get; set; }
public int Quantity { get; set; }
public string PictureUrl { get; set; }
}
}

View File

@ -3,23 +3,39 @@ using System.Collections.Generic;
namespace Microsoft.eShopOnContainers.Mobile.Shopping.HttpAggregator.Models
{
public class OrderData
{
public string OrderNumber { get; set; }
public DateTime Date { get; set; }
public string Status { get; set; }
public decimal Total { get; set; }
public string Description { get; set; }
public string City { get; set; }
public string Street { get; set; }
public string State { get; set; }
public string Country { get; set; }
public string ZipCode { get; set; }
public string CardNumber { get; set; }
public string CardHolderName { get; set; }
public bool IsDraft { get; set; }
public DateTime CardExpiration { get; set; }
public string CardExpirationShort { get; set; }
public string CardSecurityNumber { get; set; }
public int CardTypeId { get; set; }
@ -28,4 +44,5 @@ namespace Microsoft.eShopOnContainers.Mobile.Shopping.HttpAggregator.Models
public List<OrderItemData> OrderItems { get; } = new List<OrderItemData>();
}
}

View File

@ -1,12 +1,19 @@
namespace Microsoft.eShopOnContainers.Mobile.Shopping.HttpAggregator.Models
{
public class OrderItemData
{
public int ProductId { get; set; }
public string ProductName { get; set; }
public decimal UnitPrice { get; set; }
public decimal Discount { get; set; }
public int Units { get; set; }
public string PictureUrl { get; set; }
}
}

View File

@ -0,0 +1,16 @@
namespace Microsoft.eShopOnContainers.Mobile.Shopping.HttpAggregator.Models
{
public class UpdateBasketItemData
{
public string BasketItemId { get; set; }
public int NewQty { get; set; }
public UpdateBasketItemData()
{
NewQty = 0;
}
}
}

View File

@ -2,6 +2,7 @@
namespace Microsoft.eShopOnContainers.Mobile.Shopping.HttpAggregator.Models
{
public class UpdateBasketItemsRequest
{
@ -15,14 +16,4 @@ namespace Microsoft.eShopOnContainers.Mobile.Shopping.HttpAggregator.Models
}
}
public class UpdateBasketItemData
{
public string BasketItemId { get; set; }
public int NewQty { get; set; }
public UpdateBasketItemData()
{
NewQty = 0;
}
}
}

View File

@ -2,6 +2,7 @@
namespace Microsoft.eShopOnContainers.Mobile.Shopping.HttpAggregator.Models
{
public class UpdateBasketRequest
{
public string BuyerId { get; set; }
@ -9,10 +10,4 @@ namespace Microsoft.eShopOnContainers.Mobile.Shopping.HttpAggregator.Models
public IEnumerable<UpdateBasketRequestItemData> Items { get; set; }
}
public class UpdateBasketRequestItemData
{
public string Id { get; set; } // Basket id
public int ProductId { get; set; } // Catalog item id
public int Quantity { get; set; } // Quantity
}
}

View File

@ -0,0 +1,13 @@
namespace Microsoft.eShopOnContainers.Mobile.Shopping.HttpAggregator.Models
{
public class UpdateBasketRequestItemData
{
public string Id { get; set; } // Basket id
public int ProductId { get; set; } // Catalog item id
public int Quantity { get; set; } // Quantity
}
}

View File

@ -1,10 +1,8 @@
using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Server.Kestrel.Core;
using Microsoft.Extensions.Configuration;
using Serilog;
using System.IO;
using System.Net;
namespace Microsoft.eShopOnContainers.Mobile.Shopping.HttpAggregator
{

View File

@ -1,14 +1,12 @@
using Grpc.Net.Client;
using GrpcBasket;
using Microsoft.eShopOnContainers.Mobile.Shopping.HttpAggregator.Config;
using Microsoft.eShopOnContainers.Mobile.Shopping.HttpAggregator.Models;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using System;
using System.Linq;
using System.Net.Http;
using System.Threading.Tasks;
using GrpcBasket;
using Grpc.Core;
namespace Microsoft.eShopOnContainers.Mobile.Shopping.HttpAggregator.Services
{

View File

@ -1,5 +1,4 @@
using CatalogApi;
using Grpc.Net.Client;
using Microsoft.eShopOnContainers.Mobile.Shopping.HttpAggregator.Config;
using Microsoft.eShopOnContainers.Mobile.Shopping.HttpAggregator.Models;
using Microsoft.Extensions.Options;

View File

@ -1,9 +1,8 @@
using System.Net.Http;
using System.Threading.Tasks;
using System;
using Grpc.Core;
using Serilog;
using Grpc.Core;
using Grpc.Net.Client;
using Serilog;
using System;
using System.Threading.Tasks;
namespace Microsoft.eShopOnContainers.Mobile.Shopping.HttpAggregator.Services
{

View File

@ -1,4 +1,4 @@
using Grpc.Net.Client;
using GrpcOrdering;
using Microsoft.eShopOnContainers.Mobile.Shopping.HttpAggregator.Config;
using Microsoft.eShopOnContainers.Mobile.Shopping.HttpAggregator.Models;
using Microsoft.Extensions.Logging;
@ -6,7 +6,6 @@ using Microsoft.Extensions.Options;
using System.Linq;
using System.Net.Http;
using System.Threading.Tasks;
using GrpcOrdering;
namespace Microsoft.eShopOnContainers.Mobile.Shopping.HttpAggregator.Services
{

View File

@ -1,17 +1,18 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Collections.Generic;
namespace Microsoft.eShopOnContainers.Web.Shopping.HttpAggregator.Config
{
public class UrlsConfig
{
public class CatalogOperations
{
// grpc call under REST must go trough port 80
public static string GetItemById(int id) => $"/api/v1/catalog/items/{id}";
public static string GetItemById(string ids) => $"/api/v1/catalog/items/ids/{string.Join(',', ids)}";
// REST call standard must go through port 5000
public static string GetItemsById(IEnumerable<int> ids) => $":5000/api/v1/catalog/items?ids={string.Join(',', ids)}";
}
@ -19,6 +20,7 @@ namespace Microsoft.eShopOnContainers.Web.Shopping.HttpAggregator.Config
public class BasketOperations
{
public static string GetItemById(string id) => $"/api/v1/basket/{id}";
public static string UpdateBasket() => "/api/v1/basket";
}
@ -28,10 +30,16 @@ namespace Microsoft.eShopOnContainers.Web.Shopping.HttpAggregator.Config
}
public string Basket { get; set; }
public string Catalog { get; set; }
public string Orders { get; set; }
public string GrpcBasket { get; set; }
public string GrpcCatalog { get; set; }
public string GrpcOrdering { get; set; }
}
}

View File

@ -3,12 +3,9 @@ using Microsoft.AspNetCore.Mvc;
using Microsoft.eShopOnContainers.Web.Shopping.HttpAggregator.Models;
using Microsoft.eShopOnContainers.Web.Shopping.HttpAggregator.Services;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Threading.Tasks;
using Serilog;
using Newtonsoft.Json;
namespace Microsoft.eShopOnContainers.Web.Shopping.HttpAggregator.Controllers
{

View File

@ -1,8 +1,4 @@
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace Microsoft.eShopOnContainers.Web.Shopping.HttpAggregator.Controllers
{

View File

@ -2,9 +2,6 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.eShopOnContainers.Web.Shopping.HttpAggregator.Models;
using Microsoft.eShopOnContainers.Web.Shopping.HttpAggregator.Services;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Threading.Tasks;

View File

@ -1,11 +1,11 @@
namespace Microsoft.eShopOnContainers.Web.Shopping.HttpAggregator.Filters
{
using Microsoft.AspNetCore.Authorization;
using Microsoft.OpenApi.Models;
using Swashbuckle.AspNetCore.SwaggerGen;
using System.Collections.Generic;
using System.Linq;
using Microsoft.AspNetCore.Authorization;
using Microsoft.OpenApi.Models;
using Swashbuckle.AspNetCore.SwaggerGen;
using System.Collections.Generic;
using System.Linq;
namespace Microsoft.eShopOnContainers.Web.Shopping.HttpAggregator.Filters
{
namespace Basket.API.Infrastructure.Filters
{
public class AuthorizeCheckOperationFilter : IOperationFilter

View File

@ -1,13 +1,10 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace Microsoft.eShopOnContainers.Web.Shopping.HttpAggregator.Models
namespace Microsoft.eShopOnContainers.Web.Shopping.HttpAggregator.Models
{
public class AddBasketItemRequest
{
public int CatalogItemId { get; set; }
public string BasketId { get; set; }
public int Quantity { get; set; }
@ -17,4 +14,5 @@ namespace Microsoft.eShopOnContainers.Web.Shopping.HttpAggregator.Models
Quantity = 1;
}
}
}

View File

@ -2,6 +2,7 @@
namespace Microsoft.eShopOnContainers.Web.Shopping.HttpAggregator.Models
{
public class BasketData
{
public string BuyerId { get; set; }
@ -10,7 +11,6 @@ namespace Microsoft.eShopOnContainers.Web.Shopping.HttpAggregator.Models
public BasketData()
{
}
public BasketData(string buyerId)
@ -19,15 +19,4 @@ namespace Microsoft.eShopOnContainers.Web.Shopping.HttpAggregator.Models
}
}
public class BasketDataItem
{
public string Id { get; set; }
public int ProductId { get; set; }
public string ProductName { get; set; }
public decimal UnitPrice { get; set; }
public decimal OldUnitPrice { get; set; }
public int Quantity { get; set; }
public string PictureUrl { get; set; }
}
}

View File

@ -0,0 +1,21 @@
namespace Microsoft.eShopOnContainers.Web.Shopping.HttpAggregator.Models
{
public class BasketDataItem
{
public string Id { get; set; }
public int ProductId { get; set; }
public string ProductName { get; set; }
public decimal UnitPrice { get; set; }
public decimal OldUnitPrice { get; set; }
public int Quantity { get; set; }
public string PictureUrl { get; set; }
}
}

View File

@ -1,5 +1,6 @@
namespace Microsoft.eShopOnContainers.Web.Shopping.HttpAggregator.Models
{
public class CatalogItem
{
public int Id { get; set; }
@ -10,4 +11,5 @@
public string PictureUri { get; set; }
}
}

View File

@ -1,27 +1,41 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace Microsoft.eShopOnContainers.Web.Shopping.HttpAggregator.Models
{
public class OrderData
{
public string OrderNumber { get; set; }
public DateTime Date { get; set; }
public string Status { get; set; }
public decimal Total { get; set; }
public string Description { get; set; }
public string City { get; set; }
public string Street { get; set; }
public string State { get; set; }
public string Country { get; set; }
public string ZipCode { get; set; }
public string CardNumber { get; set; }
public string CardHolderName { get; set; }
public bool IsDraft { get; set; }
public DateTime CardExpiration { get; set; }
public string CardExpirationShort { get; set; }
public string CardSecurityNumber { get; set; }
public int CardTypeId { get; set; }
@ -30,4 +44,5 @@ namespace Microsoft.eShopOnContainers.Web.Shopping.HttpAggregator.Models
public List<OrderItemData> OrderItems { get; } = new List<OrderItemData>();
}
}

View File

@ -1,17 +1,19 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace Microsoft.eShopOnContainers.Web.Shopping.HttpAggregator.Models
namespace Microsoft.eShopOnContainers.Web.Shopping.HttpAggregator.Models
{
public class OrderItemData
{
public int ProductId { get; set; }
public string ProductName { get; set; }
public decimal UnitPrice { get; set; }
public decimal Discount { get; set; }
public int Units { get; set; }
public string PictureUrl { get; set; }
}
}

View File

@ -0,0 +1,16 @@
namespace Microsoft.eShopOnContainers.Web.Shopping.HttpAggregator.Models
{
public class UpdateBasketItemData
{
public string BasketItemId { get; set; }
public int NewQty { get; set; }
public UpdateBasketItemData()
{
NewQty = 0;
}
}
}

View File

@ -1,13 +1,10 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Collections.Generic;
namespace Microsoft.eShopOnContainers.Web.Shopping.HttpAggregator.Models
{
public class UpdateBasketItemsRequest
{
public string BasketId { get; set; }
public ICollection<UpdateBasketItemData> Updates { get; set; }
@ -18,14 +15,4 @@ namespace Microsoft.eShopOnContainers.Web.Shopping.HttpAggregator.Models
}
}
public class UpdateBasketItemData
{
public string BasketItemId { get; set; }
public int NewQty { get; set; }
public UpdateBasketItemData()
{
NewQty = 0;
}
}
}

View File

@ -1,10 +1,8 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Collections.Generic;
namespace Microsoft.eShopOnContainers.Web.Shopping.HttpAggregator.Models
{
public class UpdateBasketRequest
{
public string BuyerId { get; set; }
@ -12,10 +10,4 @@ namespace Microsoft.eShopOnContainers.Web.Shopping.HttpAggregator.Models
public IEnumerable<UpdateBasketRequestItemData> Items { get; set; }
}
public class UpdateBasketRequestItemData
{
public string Id { get; set; } // Basket id
public int ProductId { get; set; } // Catalog item id
public int Quantity { get; set; } // Quantity
}
}

View File

@ -0,0 +1,11 @@
namespace Microsoft.eShopOnContainers.Web.Shopping.HttpAggregator.Models
{
public class UpdateBasketRequestItemData
{
public string Id { get; set; } // Basket id
public int ProductId { get; set; } // Catalog item id
public int Quantity { get; set; } // Quantity
}
}

View File

@ -1,12 +1,11 @@
using Microsoft.eShopOnContainers.Web.Shopping.HttpAggregator.Config;
using GrpcBasket;
using Microsoft.eShopOnContainers.Web.Shopping.HttpAggregator.Config;
using Microsoft.eShopOnContainers.Web.Shopping.HttpAggregator.Models;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using System.Threading.Tasks;
using Grpc.Net.Client;
using System.Linq;
using GrpcBasket;
using System.Net.Http;
using System.Threading.Tasks;
namespace Microsoft.eShopOnContainers.Web.Shopping.HttpAggregator.Services
{

View File

@ -1,15 +1,13 @@
using Microsoft.eShopOnContainers.Web.Shopping.HttpAggregator.Config;
using CatalogApi;
using Microsoft.eShopOnContainers.Web.Shopping.HttpAggregator.Config;
using Microsoft.eShopOnContainers.Web.Shopping.HttpAggregator.Models;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Threading.Tasks;
using CatalogApi;
using Grpc.Net.Client;
using System;
using static CatalogApi.Catalog;
using System.Linq;
namespace Microsoft.eShopOnContainers.Web.Shopping.HttpAggregator.Services
{

View File

@ -1,8 +1,8 @@
using System.Threading.Tasks;
using System;
using Grpc.Core;
using Serilog;
using Grpc.Core;
using Grpc.Net.Client;
using Serilog;
using System;
using System.Threading.Tasks;
namespace Microsoft.eShopOnContainers.Web.Shopping.HttpAggregator.Services
{

View File

@ -1,14 +1,11 @@
using Grpc.Net.Client;
using GrpcOrdering;
using Microsoft.eShopOnContainers.Web.Shopping.HttpAggregator.Config;
using Microsoft.eShopOnContainers.Web.Shopping.HttpAggregator.Models;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using System;
using System.Linq;
using System.Net.Http;
using System.Threading.Tasks;
using GrpcOrdering;
using Grpc.Core;
namespace Microsoft.eShopOnContainers.Web.Shopping.HttpAggregator.Services
{

View File

@ -5,7 +5,6 @@ using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Diagnostics.HealthChecks;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.eShopOnContainers.Web.Shopping.HttpAggregator.Config;
using Microsoft.eShopOnContainers.Web.Shopping.HttpAggregator.Filters.Basket.API.Infrastructure.Filters;
using Microsoft.eShopOnContainers.Web.Shopping.HttpAggregator.Infrastructure;