Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: format all documents for code linting action #150

Merged
merged 1 commit into from
Dec 16, 2024
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
fix: format all documents for code linting action
  • Loading branch information
Sharif-C committed Dec 16, 2024
commit 787e2cb4204e6839ec4cc38e34449d2f5c8c6cb5
34 changes: 17 additions & 17 deletions api/Controllers/AddressesController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public IActionResult Create([FromBody] AddressRequest req)

if (newAddress == null) throw new ApiFlowException("Saving new Address failed.");

return Ok(new
return Ok(new
{
message = "Address created",
new_address = new AddressResponse
Expand All @@ -42,11 +42,11 @@ public IActionResult Create([FromBody] AddressRequest req)
[HttpPut("{id}")]
public IActionResult Update(Guid id, [FromBody] AddressRequest req)
{
Address? updateAddress = _addressProvider.Update(id,req);
Address? updateAddress = _addressProvider.Update(id, req);

if (updateAddress == null) throw new ApiFlowException($"Address not found for id '{id}'");

return Ok(new
return Ok(new
{
message = "Address updated",
new_address = new AddressResponse
Expand All @@ -66,26 +66,26 @@ public IActionResult Update(Guid id, [FromBody] AddressRequest req)

[HttpGet()]
public IActionResult ShowAll() => Ok(_addressProvider.GetAll().Select(a => new AddressResponse
{
Id = a.Id,
Street = a.Street,
HouseNumber = a.HouseNumber,
HouseNumberExtension = a.HouseNumberExtension,
HouseNumberExtensionExtra = a.HouseNumberExtensionExtra,
ZipCode = a.ZipCode,
City = a.City,
Province = a.Province,
CountryCode = a.CountryCode
}));
{
Id = a.Id,
Street = a.Street,
HouseNumber = a.HouseNumber,
HouseNumberExtension = a.HouseNumberExtension,
HouseNumberExtensionExtra = a.HouseNumberExtensionExtra,
ZipCode = a.ZipCode,
City = a.City,
Province = a.Province,
CountryCode = a.CountryCode
}));

[HttpGet("{id}")]
public IActionResult ShowSingle(Guid id)
{
Address? foundAddress = _addressProvider.GetById(id);

if (foundAddress == null) throw new ApiFlowException($"Address not found for id '{id}'");

return Ok(new
return Ok(new
{
message = "Address found",
new_address = new AddressResponse
Expand All @@ -109,7 +109,7 @@ public IActionResult Delete(Guid id)

if (deletedAddress == null) throw new ApiFlowException($"Address not found for id '{id}'");

return Ok(new
return Ok(new
{
message = "Address Deleted",
new_address = new AddressResponse
Expand Down
4 changes: 2 additions & 2 deletions api/Controllers/AuthController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ public async Task<IActionResult> GenerateToken([FromQuery] string role)
var token = await _tokenService.GenerateToken(role.ToLower());
return Ok(new { Token = token });
}

[HttpGet("admin-only")]
[Authorize(Roles = "admin,operative")]
public IActionResult AdminOnly()
{
return Ok(new{message = "Admin Only Authorized."});
return Ok(new { message = "Admin Only Authorized." });
}
}
2 changes: 1 addition & 1 deletion api/Controllers/ClientsController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public IActionResult Update(Guid id, [FromBody] ClientRequest req)

}


[HttpGet("{id}")]
public IActionResult ShowSingle(Guid id)
{
Expand Down
24 changes: 12 additions & 12 deletions api/Controllers/ContactsController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ public IActionResult Create([FromBody] ContactRequest req)
{
Contact? newContact = _contactProvider.Create(req);

if (newContact == null) NotFound(new{message = "Contact creation failed"});
if (newContact == null) NotFound(new { message = "Contact creation failed" });

return Ok(new
{
{
message = "Contact created!",
Contact = new ContactResponse
{
Expand All @@ -31,7 +31,7 @@ public IActionResult Create([FromBody] ContactRequest req)
}
});
}

[HttpPut("{id}")]
public IActionResult Update(Guid id, [FromBody] ContactRequest req)
{
Expand All @@ -52,15 +52,15 @@ public IActionResult Update(Guid id, [FromBody] ContactRequest req)
}
});
}

[HttpGet("{id}")]
public IActionResult ShowSingle(Guid id)
{
Contact? foundContact = _contactProvider.GetById(id);

if (foundContact == null)
return NotFound(new { message = $"Contact not found for id {id}" });

return Ok(new
{
message = "Contact found!",
Expand All @@ -76,11 +76,11 @@ public IActionResult ShowSingle(Guid id)

[HttpGet()]
public IActionResult ShowAll() => Ok(_contactProvider.GetAll()?.Select(c => new ContactResponse
{
Id = c.Id,
Name = c.Name,
Phone = c.Phone,
Email = c.Email
}).ToList());
{
Id = c.Id,
Name = c.Name,
Phone = c.Phone,
Email = c.Email
}).ToList());

}
6 changes: 3 additions & 3 deletions api/Controllers/InventoriesController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ public IActionResult Create([FromBody] InventoryRequest req)

[HttpPut("{id}")]
public IActionResult Update(Guid id, [FromBody] InventoryRequest req)
{
{
Inventory? updatedInventory = _inventoriesProvider.Update(id, req);
if(updatedInventory == null) return NotFound(new {message = $"Inventory not found for id '{id}'"});
if (updatedInventory == null) return NotFound(new { message = $"Inventory not found for id '{id}'" });

List<Location> locations = _locationsProvider.GetLocationsByInventoryId(updatedInventory.Id);
Dictionary<string, int> calculatedValues = _inventoriesProvider.GetCalculatedValues(updatedInventory.Id);
Expand Down Expand Up @@ -96,7 +96,7 @@ public IActionResult Delete(Guid id)
Dictionary<string, int> calculatedValues = _inventoriesProvider.GetCalculatedValues(foundInventory.Id);

Inventory? deletedInventory = _inventoriesProvider.Delete(id);
if(deletedInventory == null) throw new ApiFlowException("Failed to delete inventory");
if (deletedInventory == null) throw new ApiFlowException("Failed to delete inventory");

return Ok(new
{
Expand Down
39 changes: 23 additions & 16 deletions api/Controllers/ItemGroupsController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,32 +29,39 @@ public IActionResult Create([FromBody] ItemGroupRequest req)
}

[HttpPut("{id}")]
public IActionResult Update(Guid id, [FromBody] ItemGroupRequest req){
ItemGroup? updatedItemGroup = _itemGroupProvider.Update(id,req);
if(updatedItemGroup == null) return NotFound(new {message = $"Item group not found for id '{id}'"});

return Ok(new {
message = "Item group updated.",
updated_item_group = new ItemGroupResponse {
Id = updatedItemGroup.Id,
Name = updatedItemGroup.Name,
public IActionResult Update(Guid id, [FromBody] ItemGroupRequest req)
{
ItemGroup? updatedItemGroup = _itemGroupProvider.Update(id, req);
if (updatedItemGroup == null) return NotFound(new { message = $"Item group not found for id '{id}'" });

return Ok(new
{
message = "Item group updated.",
updated_item_group = new ItemGroupResponse
{
Id = updatedItemGroup.Id,
Name = updatedItemGroup.Name,
Description = updatedItemGroup.Description
}
}
}
);
}

[HttpDelete("{id}")]
public IActionResult Delete(Guid id)
{
ItemGroup? deletedItemGroup = _itemGroupProvider.Delete(id);
if (deletedItemGroup == null) throw new ApiFlowException($"Item group not found for id '{id}'");

return Ok(new {deleted_item_group = new ItemGroupResponse{
Id = deletedItemGroup.Id,
Name = deletedItemGroup.Name,
Description = deletedItemGroup.Description
}});
return Ok(new
{
deleted_item_group = new ItemGroupResponse
{
Id = deletedItemGroup.Id,
Name = deletedItemGroup.Name,
Description = deletedItemGroup.Description
}
});
}

[HttpGet("{id}")]
Expand Down
39 changes: 22 additions & 17 deletions api/Controllers/ItemLinesController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,23 @@ public IActionResult Create([FromBody] ItemLineRequest req)
}

[HttpPut("{id}")]
public IActionResult Update(Guid id, [FromBody] ItemLineRequest req){
ItemLine? updatedItemLine = _itemLinesProvider.Update(id,req);
if(updatedItemLine == null) return NotFound(new {message = $"Item line not found for id '{id}'"});

return Ok(new {
message = "Item Line updated!",
updated_item_line = new ItemLineResponse {
Id = updatedItemLine.Id,
Name = updatedItemLine.Name,
public IActionResult Update(Guid id, [FromBody] ItemLineRequest req)
{
ItemLine? updatedItemLine = _itemLinesProvider.Update(id, req);
if (updatedItemLine == null) return NotFound(new { message = $"Item line not found for id '{id}'" });

return Ok(new
{
message = "Item Line updated!",
updated_item_line = new ItemLineResponse
{
Id = updatedItemLine.Id,
Name = updatedItemLine.Name,
Description = updatedItemLine.Description,
CreatedAt = updatedItemLine.CreatedAt,
UpdatedAt = updatedItemLine.UpdatedAt
}
}
}
);
}

Expand All @@ -57,14 +60,16 @@ public IActionResult Delete(Guid id)
ItemLine? deletedItemLine = _itemLinesProvider.Delete(id);
if (deletedItemLine == null) throw new ApiFlowException($"Item line not found for id '{id}'");

return Ok(new {
return Ok(new
{
message = "Item Line deleted!",
deleted_item_line = new ItemLineResponse{
Id = deletedItemLine.Id,
Name = deletedItemLine.Name,
Description = deletedItemLine.Description,
CreatedAt = deletedItemLine.CreatedAt,
UpdatedAt = deletedItemLine.UpdatedAt
deleted_item_line = new ItemLineResponse
{
Id = deletedItemLine.Id,
Name = deletedItemLine.Name,
Description = deletedItemLine.Description,
CreatedAt = deletedItemLine.CreatedAt,
UpdatedAt = deletedItemLine.UpdatedAt
}
});
}
Expand Down
41 changes: 23 additions & 18 deletions api/Controllers/ItemTypesController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,23 @@ public IActionResult Create([FromBody] ItemTypeRequest req)
}

[HttpPut("{id}")]
public IActionResult Update(Guid id, [FromBody] ItemTypeRequest req){
ItemType? updatedItemType = _itemTypesProvider.Update(id,req);
if(updatedItemType == null) return NotFound(new {message = $"Item Type not found for id '{id}'"});

return Ok(new {
message = "Item Type updated!",
updated_item_type = new ItemTypeResponse {
Id = updatedItemType.Id,
Name = updatedItemType.Name,
public IActionResult Update(Guid id, [FromBody] ItemTypeRequest req)
{
ItemType? updatedItemType = _itemTypesProvider.Update(id, req);
if (updatedItemType == null) return NotFound(new { message = $"Item Type not found for id '{id}'" });

return Ok(new
{
message = "Item Type updated!",
updated_item_type = new ItemTypeResponse
{
Id = updatedItemType.Id,
Name = updatedItemType.Name,
Description = updatedItemType.Description,
CreatedAt = updatedItemType.CreatedAt,
UpdatedAt = updatedItemType.UpdatedAt
}
}
}
);
}

Expand All @@ -57,14 +60,16 @@ public IActionResult Delete(Guid id)
ItemType? deletedItemType = _itemTypesProvider.Delete(id);
if (deletedItemType == null) throw new ApiFlowException($"Item Type not found for id '{id}'");

return Ok(new {
return Ok(new
{
message = "Item Type deleted!",
deleted_item_type = new ItemTypeResponse{
Id = deletedItemType.Id,
Name = deletedItemType.Name,
Description = deletedItemType.Description,
CreatedAt = deletedItemType.CreatedAt,
UpdatedAt = deletedItemType.UpdatedAt
deleted_item_type = new ItemTypeResponse
{
Id = deletedItemType.Id,
Name = deletedItemType.Name,
Description = deletedItemType.Description,
CreatedAt = deletedItemType.CreatedAt,
UpdatedAt = deletedItemType.UpdatedAt
}
});
}
Expand All @@ -85,7 +90,7 @@ public IActionResult ShowSingle(Guid id)
UpdatedAt = foundItemType.UpdatedAt
});
}

[HttpGet()]
public IActionResult ShowAll() => Ok(_itemTypesProvider.GetAll().Select(it => new ItemTypeResponse
{
Expand Down
Loading
Loading