Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .vs/JafnaEcommerceApi/v17/.suo
Binary file not shown.
27 changes: 27 additions & 0 deletions .vs/JafnaEcommerceApi/v17/DocumentLayout.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"Version": 1,
"WorkspaceRootPath": "D:\\projects\\WEB API APPS\\Development\\code review\\CodeReviews.Console.EcommerceApi\\",
"Documents": [],
"DocumentGroupContainers": [
{
"Orientation": 0,
"VerticalTabListWidth": 256,
"DocumentGroups": [
{
"DockedWidth": 200,
"SelectedChildIndex": -1,
"Children": [
{
"$type": "Bookmark",
"Name": "ST:128:0:{116d2292-e37d-41cd-a077-ebacac4c8cc4}"
},
{
"$type": "Bookmark",
"Name": "ST:128:0:{1fc202d4-d401-403c-9834-5b218574bb67}"
}
]
}
]
}
]
}
63 changes: 63 additions & 0 deletions freddypositive.ecomerceapi/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
###############################################################################
# Set default behavior to automatically normalize line endings.
###############################################################################
* text=auto

###############################################################################
# Set default behavior for command prompt diff.
#
# This is need for earlier builds of msysgit that does not have it on by
# default for csharp files.
# Note: This is only used by command line
###############################################################################
#*.cs diff=csharp

###############################################################################
# Set the merge driver for project and solution files
#
# Merging from the command prompt will add diff markers to the files if there
# are conflicts (Merging from VS is not affected by the settings below, in VS
# the diff markers are never inserted). Diff markers may cause the following
# file extensions to fail to load in VS. An alternative would be to treat
# these files as binary and thus will always conflict and require user
# intervention with every merge. To do so, just uncomment the entries below
###############################################################################
#*.sln merge=binary
#*.csproj merge=binary
#*.vbproj merge=binary
#*.vcxproj merge=binary
#*.vcproj merge=binary
#*.dbproj merge=binary
#*.fsproj merge=binary
#*.lsproj merge=binary
#*.wixproj merge=binary
#*.modelproj merge=binary
#*.sqlproj merge=binary
#*.wwaproj merge=binary

###############################################################################
# behavior for image files
#
# image files are treated as binary by default.
###############################################################################
#*.jpg binary
#*.png binary
#*.gif binary

###############################################################################
# diff behavior for common document formats
#
# Convert binary document formats to text before diffing them. This feature
# is only available from the command line. Turn it on by uncommenting the
# entries below.
###############################################################################
#*.doc diff=astextplain
#*.DOC diff=astextplain
#*.docx diff=astextplain
#*.DOCX diff=astextplain
#*.dot diff=astextplain
#*.DOT diff=astextplain
#*.pdf diff=astextplain
#*.PDF diff=astextplain
#*.rtf diff=astextplain
#*.RTF diff=astextplain
File renamed without changes.
25 changes: 25 additions & 0 deletions freddypositive.ecomerceapi/JafnaEcommerceApi.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.13.35818.85 d17.13
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "JafnaEcommerceApi", "JafnaEcommerceApi\JafnaEcommerceApi.csproj", "{533FB58A-287D-40BE-99DD-2C0A7C3AE478}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{533FB58A-287D-40BE-99DD-2C0A7C3AE478}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{533FB58A-287D-40BE-99DD-2C0A7C3AE478}.Debug|Any CPU.Build.0 = Debug|Any CPU
{533FB58A-287D-40BE-99DD-2C0A7C3AE478}.Release|Any CPU.ActiveCfg = Release|Any CPU
{533FB58A-287D-40BE-99DD-2C0A7C3AE478}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {5E52E7E8-BBD8-454F-93EB-AEF0C371194E}
EndGlobalSection
EndGlobal
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using AutoMapper;
using JafnaEcommerceApi.Models.DTOs.CategoryDTOs;
using JafnaEcommerceApi.Models.Entities;

namespace JafnaEcommerceApi.AutoMapper;

public class CategoryProfile : Profile
{
public CategoryProfile()
{
CreateMap<Category, CategoryDto>();
CreateMap<CategoryCreateDto, Category>();
CreateMap<CategoryUpdateDto, Category>()
.ForAllMembers(opt =>
opt.Condition((src, dest, srcMember) =>
srcMember != null && !(srcMember is string s && string.IsNullOrWhiteSpace(s)))); ;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using AutoMapper;
using JafnaEcommerceApi.Models.DTOs.ProductDTOs;
using JafnaEcommerceApi.Models.Entities;

namespace JafnaEcommerceApi.AutoMapper;

public class ProductProfile : Profile
{
public ProductProfile()
{
CreateMap<Product, ProductDto>();
CreateMap<ProductCreateDto, Product>();
CreateMap<ProductUpdateDto, Product>()
.ForAllMembers(opt =>
opt.Condition((src, dest, srcMember) =>
srcMember != null && !(srcMember is string s && string.IsNullOrWhiteSpace(s))));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using AutoMapper;
using JafnaEcommerceApi.Models.DTOs.SaleDTOs;
using JafnaEcommerceApi.Models.Entities;
namespace JafnaEcommerceApi.AutoMapper;

public class SaleDetailProfile : Profile
{
public SaleDetailProfile()
{
CreateMap<SaleDetail, SaleDetailDto>();


CreateMap<SaleDetailDto, SaleDetail>();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using AutoMapper;
using JafnaEcommerceApi.Models.DTOs.SaleDTOs;
using JafnaEcommerceApi.Models.Entities;

namespace JafnaEcommerceApi.AutoMapper;

public class SaleProfile : Profile
{
public SaleProfile()
{
CreateMap<Sale, SaleDto>();

}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
using JafnaEcommerceApi.Models.DTOs.CategoryDTOs;
using JafnaEcommerceApi.Services;
using Microsoft.AspNetCore.Mvc;
using JafnaEcommerceApi.Models.DTOs.APIResponse;
using JafnaEcommerceApi.Models.DTOs.PaginationDTOs;

namespace JafnaEcommerceApi.Controllers;

[ApiController]
[Route("api/[controller]")]
public class CategoryController : ControllerBase
{
private readonly ICategoryService _categoryService;

public CategoryController(ICategoryService categoryService)
{
_categoryService = categoryService;
}

[HttpPost]
public async Task<ActionResult> CreateAsync([FromBody] CategoryCreateDto categoryCreateDto)
{
await _categoryService.Create(categoryCreateDto);
return Ok(ApiResponse<object>.Success(null, "Category created successfully"));
}

[HttpPut("{categoryId}")]
public async Task<ActionResult> UpdateAsync([FromRoute] int categoryId, [FromBody] CategoryUpdateDto categoryUpdateDto)
{
await _categoryService.Update(categoryId, categoryUpdateDto);
return Ok(ApiResponse<object>.Success(null, "Category updated successfully"));

}

[HttpDelete("{categoryId}")]
public async Task<ActionResult> DeleteAsync([FromRoute]int categoryId)
{
await _categoryService.Delete(categoryId);
return Ok(ApiResponse<object>.Success(null, "Category deleted successfully"));
}

[HttpGet]
public async Task<ActionResult> GetAllAsync([FromQuery] int pageNumber = 1, [FromQuery] int pageSize = 10)
{
var categoryList = await _categoryService.GetAll(pageNumber, pageSize);
return Ok(ApiResponse<PagedResponse<CategoryDto>>.Success(categoryList, "Categories obtained successfully"));
}


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
using JafnaEcommerceApi.Models.DTOs.APIResponse;
using JafnaEcommerceApi.Models.DTOs.PaginationDTOs;
using JafnaEcommerceApi.Models.DTOs.ProductDTOs;
using JafnaEcommerceApi.Services;
using Microsoft.AspNetCore.Mvc;

namespace JafnaEcommerceApi.Controllers;

[ApiController]
[Route("api/[controller]")]
public class ProductController : ControllerBase
{
private readonly IProductService _productService;

public ProductController(IProductService productService)
{
_productService = productService;
}

[HttpPost]
public async Task<ActionResult> CreateAsync([FromBody] ProductCreateDto productCreateDto)
{
await _productService.CreateAsync(productCreateDto);
return Ok(ApiResponse<object>.Success(null, "Product created successfully"));
}

[HttpPut("{productId}")]
public async Task<ActionResult> UpdateAsync([FromRoute] int productId, [FromBody] ProductUpdateDto productUpdateDto)
{
await _productService.UpdateAsync(productId, productUpdateDto);
return Ok(ApiResponse<object>.Success(null, "Product updated successfully."));

}

[HttpDelete("{productId}")]
public async Task<ActionResult> DeleteAsync([FromRoute] int productId)
{
await _productService.DeleteAsync(productId);
return Ok(ApiResponse<object>.Success(null, "Product deleted successfully."));
}

[HttpGet]
public async Task<ActionResult> GetAllAsync([FromQuery] int pageNumber = 1,[FromQuery] int pageSize = 10)
{
var productList = await _productService.GetAllAsync(pageNumber, pageSize);
return Ok(ApiResponse<PagedResponse<ProductDto>>.Success(productList, "Products obtained successfully"));
}

[HttpGet("{categoryId}")]
public async Task<ActionResult> GetProductsByCategoryAsync([FromRoute] int categoryId, [FromQuery] int pageNumber = 1, [FromQuery] int pageSize = 10)
{
var productsList = await _productService.GetProductsByCategoryAsync(categoryId, pageNumber, pageSize);
return Ok(ApiResponse<PagedResponse<ProductDto>>.Success(productsList, "Products obtained successfully"));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
using JafnaEcommerceApi.Models.DTOs.SaleDTOs;
using JafnaEcommerceApi.Services;
using Microsoft.AspNetCore.Mvc;
using JafnaEcommerceApi.Models.DTOs.APIResponse;
using JafnaEcommerceApi.Models.DTOs.PaginationDTOs;

namespace JafnaEcommerceApi.Controllers;

[ApiController]
[Route("api/[controller]")]
public class SalesController : ControllerBase
{
private readonly ISaleService _saleService;

public SalesController(ISaleService saleService)
{
_saleService = saleService;
}

[HttpPost]
public async Task<ActionResult> CreateAsync([FromBody] SaleCreateDto saleCreateDto)
{
await _saleService.CreateAsync(saleCreateDto);
return Ok(ApiResponse<object>.Success(null, "Sale created successfully"));
}

[HttpGet]
public async Task<ActionResult> GetAllSaleAsync([FromQuery] int pageNumber = 1, [FromQuery] int pageSize = 10)
{
var saleList = await _saleService.GetAllSaleAsync(pageNumber, pageSize);
return Ok(ApiResponse<PagedResponse<SaleDto>>.Success(saleList, "Sale obtained successfully"));
}

[HttpGet("{saleId}/details")]
public async Task<ActionResult> GetSaleDetailsAsync([FromRoute] int saleId, [FromQuery] int pageNumber = 1, [FromQuery] int pageSize = 10)
{
var detailsList = await _saleService.GetSaleDetailsAsync(saleId, pageNumber, pageSize);
return Ok(ApiResponse<PagedResponse<SaleDetailDto>>.Success(detailsList, "Sale details obtained successfully"));
}
}
Loading