Skip to content
Merged
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
2 changes: 1 addition & 1 deletion NorthwindCRUD.Tests/CategroyServiceFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public void ShouldUpdateCategory()

createdCategory.Name = "Updated Category";
createdCategory.Description = "Updated Description";
var updatedCategory = DataHelper.CategoryService.Update(createdCategory);
var updatedCategory = DataHelper.CategoryService.Update(createdCategory.CategoryId, createdCategory);

Assert.IsNotNull(updatedCategory);
updatedCategory = DataHelper2.CategoryService.GetById(updatedCategory.CategoryId);
Expand Down
2 changes: 1 addition & 1 deletion NorthwindCRUD.Tests/EmployeeServiceFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public void ShouldUpdateEmployee()
var createdEmployee = DataHelper.EmployeeService.Create(employee);

createdEmployee.Title = "Director";
var updatedEmployee = DataHelper.EmployeeService.Update(createdEmployee);
var updatedEmployee = DataHelper.EmployeeService.Update(createdEmployee.EmployeeId, createdEmployee);

Assert.IsNotNull(updatedEmployee);
updatedEmployee = DataHelper2.EmployeeService.GetById(updatedEmployee.EmployeeId);
Expand Down
2 changes: 1 addition & 1 deletion NorthwindCRUD.Tests/OrderServiceFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public void ShouldUpdateOrder()
order.CustomerId = DataHelper.CreateCustomer().CustomerId;
order.EmployeeId = DataHelper.CreateEmployee().EmployeeId;

var updatedOrder = DataHelper.OrderService.Update(order);
var updatedOrder = DataHelper.OrderService.Update(order.OrderId, order);

Assert.IsNotNull(updatedOrder);
updatedOrder = DataHelper2.OrderService.GetById(updatedOrder.OrderId);
Expand Down
2 changes: 1 addition & 1 deletion NorthwindCRUD.Tests/ProductServiceFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public void ShouldUpdateProduct()
createdProduct.UnitPrice = 15;
createdProduct.UnitsInStock = 50;

var updatedProduct = DataHelper.ProductService.Update(createdProduct);
var updatedProduct = DataHelper.ProductService.Update(createdProduct.ProductId, createdProduct);

Assert.IsNotNull(updatedProduct);
updatedProduct = DataHelper2.ProductService.GetById(updatedProduct.ProductId);
Expand Down
2 changes: 1 addition & 1 deletion NorthwindCRUD.Tests/RegionServiceFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public void ShouldUpdateRegion()
string originalRegionDescription = region.RegionDescription;
region.RegionDescription = "Updated Region";

var updatedRegion = DataHelper.RegionService.Update(region);
var updatedRegion = DataHelper.RegionService.Update(region.RegionId, region);

Assert.IsNotNull(updatedRegion);
updatedRegion = DataHelper2.RegionService.GetById(updatedRegion.RegionId);
Expand Down
2 changes: 1 addition & 1 deletion NorthwindCRUD.Tests/ShipperServiceFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public void ShouldUpdateShipper()
shipper.CompanyName = "Updated shipper company";
shipper.Phone = "555-555-5555";

var updatedShipper = DataHelper.ShipperService.Update(shipper);
var updatedShipper = DataHelper.ShipperService.Update(shipper.ShipperId, shipper);

Assert.IsNotNull(updatedShipper);
updatedShipper = DataHelper2.ShipperService.GetById(updatedShipper.ShipperId);
Expand Down
2 changes: 1 addition & 1 deletion NorthwindCRUD.Tests/SupplierServiceFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public void ShouldUpdateSupplier()
supplier.ContactName = "Updated Contact";
supplier.ContactTitle = "Updated Title";

var updatedSupplier = DataHelper.SupplierService.Update(supplier);
var updatedSupplier = DataHelper.SupplierService.Update(supplier.SupplierId, supplier);
Assert.IsNotNull(updatedSupplier);
updatedSupplier = DataHelper2.SupplierService.GetById(updatedSupplier.SupplierId);
Assert.IsNotNull(updatedSupplier);
Expand Down
2 changes: 1 addition & 1 deletion NorthwindCRUD.Tests/TerritoryServiceFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public void ShouldUpdateTerritory()

createdTerritory.TerritoryDescription = "Updated Territory";

var updatedTerritory = DataHelper.TerritoryService.Update(createdTerritory);
var updatedTerritory = DataHelper.TerritoryService.Update(createdTerritory.TerritoryId, createdTerritory);

Assert.IsNotNull(updatedTerritory);
updatedTerritory = DataHelper2.TerritoryService.GetById(updatedTerritory.TerritoryId);
Expand Down
6 changes: 3 additions & 3 deletions NorthwindCRUD/Controllers/CategoriesController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -198,16 +198,16 @@ public ActionResult<CategoryDetailsDto> Create(CategoryDto model)
}
}

[HttpPut]
[HttpPut("{id}")]
[Authorize]
public ActionResult<CategoryDto> Update(CategoryDto model)
public ActionResult<CategoryDto> Update(int id, CategoryDto model)
{
try
{
if (ModelState.IsValid)
{
var mappedModel = this.mapper.Map<CategoryDto, CategoryDb>(model);
var category = this.categoryService.Update(mappedModel);
var category = this.categoryService.Update(id, mappedModel);

if (category != null)
{
Expand Down
6 changes: 3 additions & 3 deletions NorthwindCRUD/Controllers/CustomersController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -209,16 +209,16 @@ public ActionResult<CustomerDto> Create(CustomerDto model)
}
}

[HttpPut]
[HttpPut("{id}")]
[Authorize]
public ActionResult<CustomerDto> Update(CustomerDto model)
public ActionResult<CustomerDto> Update(string id, CustomerDto model)
{
try
{
if (ModelState.IsValid)
{
var mappedModel = this.mapper.Map<CustomerDto, CustomerDb>(model);
var customer = this.customerService.Update(mappedModel);
var customer = this.customerService.Update(id, mappedModel);

if (customer != null)
{
Expand Down
6 changes: 3 additions & 3 deletions NorthwindCRUD/Controllers/EmployeesController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -304,16 +304,16 @@ public ActionResult<EmployeeDto> Create(EmployeeDto model)
}
}

[HttpPut]
[HttpPut("{id}")]
[Authorize]
public ActionResult<EmployeeDto> Update(EmployeeDto model)
public ActionResult<EmployeeDto> Update(int id, EmployeeDto model)
{
try
{
if (ModelState.IsValid)
{
var mappedModel = this.mapper.Map<EmployeeDto, EmployeeDb>(model);
var employee = this.employeeService.Update(mappedModel);
var employee = this.employeeService.Update(id, mappedModel);

if (employee != null)
{
Expand Down
6 changes: 3 additions & 3 deletions NorthwindCRUD/Controllers/OrdersController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -311,16 +311,16 @@ public ActionResult<OrderDto> Create(OrderDto model)
}
}

[HttpPut]
[HttpPut("{id}")]
[Authorize]
public ActionResult<OrderDto> Update(OrderDto model)
public ActionResult<OrderDto> Update(int id, OrderDto model)
{
try
{
if (ModelState.IsValid)
{
var mappedModel = this.mapper.Map<OrderDto, OrderDb>(model);
var order = this.orderService.Update(mappedModel);
var order = this.orderService.Update(id, mappedModel);
if (order != null)
{
return Ok(this.mapper.Map<OrderDb, OrderDto>(order));
Expand Down
6 changes: 3 additions & 3 deletions NorthwindCRUD/Controllers/ProductsController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -277,16 +277,16 @@ public ActionResult<ProductDto> Create(ProductDto model)
}
}

[HttpPut]
[HttpPut("{id}")]
[Authorize]
public ActionResult<ProductDto> Update(ProductDto model)
public ActionResult<ProductDto> Update(int id, ProductDto model)
{
try
{
if (ModelState.IsValid)
{
var mappedModel = this.mapper.Map<ProductDto, ProductDb>(model);
var product = this.productService.Update(mappedModel);
var product = this.productService.Update(id, mappedModel);

if (product != null)
{
Expand Down
6 changes: 3 additions & 3 deletions NorthwindCRUD/Controllers/RegionsController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -183,16 +183,16 @@ public ActionResult<RegionDto> Create(RegionDto model)
}
}

[HttpPut]
[HttpPut("{id}")]
[Authorize]
public ActionResult<RegionDto> Update(RegionDto model)
public ActionResult<RegionDto> Update(int id, RegionDto model)
{
try
{
if (ModelState.IsValid)
{
var mappedModel = this.mapper.Map<RegionDto, RegionDb>(model);
var region = this.regionService.Update(mappedModel);
var region = this.regionService.Update(id, mappedModel);

if (region != null)
{
Expand Down
6 changes: 3 additions & 3 deletions NorthwindCRUD/Controllers/ShippersController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -178,16 +178,16 @@ public ActionResult<ShipperDto> Create(ShipperDto model)
}
}

[HttpPut]
[HttpPut("{id}")]
[Authorize]
public ActionResult<ShipperDto> Update(ShipperDto model)
public ActionResult<ShipperDto> Update(int id, ShipperDto model)
{
try
{
if (ModelState.IsValid)
{
var mappedModel = this.mapper.Map<ShipperDto, ShipperDb>(model);
var shipper = this.shipperService.Update(mappedModel);
var shipper = this.shipperService.Update(id, mappedModel);

if (shipper != null)
{
Expand Down
6 changes: 3 additions & 3 deletions NorthwindCRUD/Controllers/SuppliersController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -178,16 +178,16 @@ public ActionResult<SupplierDto> Create(SupplierDto model)
}
}

[HttpPut]
[HttpPut("{id}")]
[Authorize]
public ActionResult<SupplierDto> Update(SupplierDto model)
public ActionResult<SupplierDto> Update(int id, SupplierDto model)
{
try
{
if (ModelState.IsValid)
{
var mappedModel = this.mapper.Map<SupplierDto, SupplierDb>(model);
var supplier = this.supplierService.Update(mappedModel);
var supplier = this.supplierService.Update(id, mappedModel);

if (supplier != null)
{
Expand Down
6 changes: 3 additions & 3 deletions NorthwindCRUD/Controllers/TerritoriesController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -214,16 +214,16 @@ public ActionResult<TerritoryDto> Create(TerritoryDto model)
}
}

[HttpPut]
[HttpPut("{id}")]
[Authorize]
public ActionResult<TerritoryDto> Update(TerritoryDto model)
public ActionResult<TerritoryDto> Update(string id, TerritoryDto model)
{
try
{
if (ModelState.IsValid)
{
var mappedModel = this.mapper.Map<TerritoryDto, TerritoryDb>(model);
var territory = this.territoryService.Update(mappedModel);
var territory = this.territoryService.Update(id, mappedModel);

if (territory != null)
{
Expand Down
4 changes: 2 additions & 2 deletions NorthwindCRUD/ControllersGraphQL/CategoryController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@ public CategoryDto Create(CategoryDto model)
}

[Mutation]
public CategoryDto? Update(CategoryDto model)
public CategoryDto? Update(int id, CategoryDto model)
{
var mappedModel = this.mapper.Map<CategoryDto, CategoryDb>(model);
var category = this.categoryService.Update(mappedModel);
var category = this.categoryService.Update(id, mappedModel);

return category != null ? this.mapper.Map<CategoryDb, CategoryDto>(category) : null;
}
Expand Down
4 changes: 2 additions & 2 deletions NorthwindCRUD/ControllersGraphQL/CustomerController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ public CustomerDto Create(CustomerDto model)
}

[Mutation]
public CustomerDto? Update(CustomerDto model)
public CustomerDto? Update(string id, CustomerDto model)
{
var mappedModel = this.mapper.Map<CustomerDto, CustomerDb>(model);
var customer = this.customerService.Update(mappedModel);
var customer = this.customerService.Update(id, mappedModel);
return customer != null ? this.mapper.Map<CustomerDb, CustomerDto>(customer) : null;
}

Expand Down
4 changes: 2 additions & 2 deletions NorthwindCRUD/ControllersGraphQL/EmployeeController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ public EmployeeDto Create(EmployeeDto model)
}

[Mutation]
public EmployeeDto? Update(EmployeeDto model)
public EmployeeDto? Update(int id, EmployeeDto model)
{
var mappedModel = this.mapper.Map<EmployeeDto, EmployeeDb>(model);
var employee = this.employeeService.Update(mappedModel);
var employee = this.employeeService.Update(id, mappedModel);
return employee != null ? this.mapper.Map<EmployeeDb, EmployeeDto>(employee) : null;
}

Expand Down
4 changes: 2 additions & 2 deletions NorthwindCRUD/ControllersGraphQL/OrderController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@ public OrderDto Create(OrderDto model)
}

[Mutation]
public OrderDto? Update(OrderDto model)
public OrderDto? Update(int id, OrderDto model)
{
var mappedModel = this.mapper.Map<OrderDto, OrderDb>(model);
var order = this.orderService.Update(mappedModel);
var order = this.orderService.Update(id, mappedModel);
return order != null ? this.mapper.Map<OrderDb, OrderDto>(order) : null;
}

Expand Down
2 changes: 1 addition & 1 deletion NorthwindCRUD/Models/Contracts/ICategory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{
public interface ICategory
{
int CategoryId { get; set; }
int CategoryId { get; }

string Description { get; set; }

Expand Down
2 changes: 1 addition & 1 deletion NorthwindCRUD/Models/Contracts/ICustomer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ namespace NorthwindCRUD.Models.Contracts
{
public interface ICustomer
{
string CustomerId { get; set; }
string CustomerId { get; }

string CompanyName { get; set; }

Expand Down
2 changes: 1 addition & 1 deletion NorthwindCRUD/Models/Contracts/IEmployee.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ namespace NorthwindCRUD.Models.Contracts
{
public interface IEmployee
{
int EmployeeId { get; set; }
int EmployeeId { get; }

string LastName { get; set; }

Expand Down
2 changes: 1 addition & 1 deletion NorthwindCRUD/Models/Contracts/IOrder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace NorthwindCRUD.Models.Contracts
{
public interface IOrder
{
int OrderId { get; set; }
int OrderId { get; }

string? CustomerId { get; set; }

Expand Down
2 changes: 1 addition & 1 deletion NorthwindCRUD/Models/Contracts/IProduct.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{
public interface IProduct
{
int ProductId { get; set; }
int ProductId { get; }

int? SupplierId { get; set; }

Expand Down
2 changes: 1 addition & 1 deletion NorthwindCRUD/Models/Contracts/IRegion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{
public interface IRegion
{
int RegionId { get; set; }
int RegionId { get; }

string RegionDescription { get; set; }
}
Expand Down
2 changes: 1 addition & 1 deletion NorthwindCRUD/Models/Contracts/IShipper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{
public interface IShipper
{
int ShipperId { get; set; }
int ShipperId { get; }

string CompanyName { get; set; }

Expand Down
2 changes: 1 addition & 1 deletion NorthwindCRUD/Models/Contracts/ISupplier.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{
public interface ISupplier
{
int SupplierId { get; set; }
int SupplierId { get; }

string? CompanyName { get; set; }

Expand Down
2 changes: 1 addition & 1 deletion NorthwindCRUD/Models/Contracts/ITerritory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{
public interface ITerritory
{
string TerritoryId { get; set; }
string TerritoryId { get; }

string TerritoryDescription { get; set; }

Expand Down
2 changes: 1 addition & 1 deletion NorthwindCRUD/Models/Dtos/CategoryDto.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace NorthwindCRUD.Models.Dtos
{
public class CategoryDto : ICategory
{
public int CategoryId { get; set; }
public int CategoryId { get; private set; }

[StringLength(500, ErrorMessage = "Description cannot exceed 500 characters.")]
public string Description { get; set; }
Expand Down
Loading