Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
c449650
Create OrderTimeOutService
hekcalion Feb 3, 2022
5e86b12
Add Entities and DbContext
hekcalion Feb 6, 2022
430016c
Add OrderController
hekcalion Feb 7, 2022
6b7f514
Downgrading EntityFramework Core to 3.1 package
hekcalion Feb 7, 2022
178c2a0
Downgrading project to .Net Core 3.1
hekcalion Feb 7, 2022
5c61161
Revert "Downgrading project to .Net Core 3.1"
hekcalion Feb 7, 2022
f396842
Revert "Revert "Downgrading project to .Net Core 3.1""
hekcalion Feb 8, 2022
08f5d42
Update BarDataBase.cs
hekcalion Feb 8, 2022
fc75e73
Update IMenuRepository.cs
hekcalion Feb 13, 2022
49e8c01
Update MenuRepository.cs
hekcalion Feb 13, 2022
2d627d9
Update MenuController.cs
hekcalion Feb 13, 2022
15b9dd2
Add method GetOrdersByStatus
hekcalion Feb 13, 2022
bfc0770
Implement GetOrdersByStatus
hekcalion Feb 13, 2022
15a5844
Update OrderController.cs
hekcalion Feb 13, 2022
a4ecb76
Update OrderTimeOut.cs
hekcalion Feb 13, 2022
4297545
Implement method UploadContentBlobAsync
hekcalion Feb 15, 2022
3f018dc
Implement report feature
hekcalion Feb 15, 2022
f3fbb58
Create profile.arm.json
hekcalion Feb 15, 2022
ec714dd
Update Program.cs
hekcalion Feb 15, 2022
6d86393
Update EnqueueCompleteOrderCommandApp.csproj
hekcalion Feb 15, 2022
9ce03a9
Update .gitignore
hekcalion Feb 15, 2022
65c507e
Revert "Update .gitignore"
hekcalion Feb 16, 2022
6f87b9a
Update BlobStorage.cs
hekcalion Feb 16, 2022
cdaa1a6
Update OrderTimeOut.cs
hekcalion Feb 16, 2022
4d98d1c
Update OrderTimeOutService.csproj
hekcalion Feb 16, 2022
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
1 change: 1 addition & 0 deletions BarAPI/BarAPI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="5.0.13" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="5.6.3" />
<PackageReference Include="System.Data.SqlClient" Version="4.8.3" />
</ItemGroup>
Expand Down
92 changes: 72 additions & 20 deletions BarAPI/Controllers/MenuController.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
using System;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc;
using System.Threading.Tasks;
using DataAccess;
using DataAccess.Domain;
using DataAccess.Data;
using DataAccess.Repository;
using System.Collections.Generic;

// For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860

namespace BarAPI.Controllers
{
Expand All @@ -21,37 +20,90 @@ public MenuController(IMenuRepository menuRepository)

// GET: api/<MenuController>
[HttpGet]
public Task<MenuItem[]> Get()
[ProducesResponseType(200, Type = typeof(List<MenuItem>))]
public async Task<List<MenuItem>> GetAll()
{
return _menuRepository.Get();
return await _menuRepository.GetAllItems();
}

// GET api/<MenuController>/name
[HttpGet("{name}")]
public Task<MenuItem> Get(string name)
// GET api/<MenuController>/id
[HttpGet("{id}")]
[ProducesResponseType(200, Type = typeof(MenuItem))]
[ProducesResponseType(404)]
public async Task<IActionResult> Get(int id)
{
return _menuRepository.GetItem(name);
MenuItem menuItem = await _menuRepository.GetItem(id);
if(menuItem == null)
{
return NotFound();
}
else
{
return Ok(menuItem);
}
}

// POST api/<MenuController>
[HttpPost]
public async Task Post([FromBody] MenuItem item)
[ProducesResponseType(201, Type = typeof(MenuItem))]
[ProducesResponseType(400)]
public async Task<IActionResult> Post([FromBody] MenuItem item)
{
await _menuRepository.Add(item);
if(item == null) return BadRequest();
if(!ModelState.IsValid) return BadRequest(ModelState);
MenuItem exist = await _menuRepository.GetItem(item.Id);
if (string.IsNullOrWhiteSpace(item.Name)) return BadRequest("Item name is Null or contain only WhiteSpace");
if (item.Price <= 0) return BadRequest("Item price must be above zero");
if (exist != null) return BadRequest($"Item with id = {item.Id} already exists");
bool isAdded = await _menuRepository.Add(item);
if (isAdded)
{
return CreatedAtAction(nameof(Post), item);
}
else
{
return BadRequest();
}
}

// PUT api/<MenuController>/5
[HttpPut("{name}")]
public void Put(string name, [FromBody] string value)
[HttpPut("{id}")]
[ProducesResponseType(204)]
[ProducesResponseType(400)]
public async Task<IActionResult> Update(int id, [FromBody] MenuItem item)
Comment thread
AshasTob marked this conversation as resolved.
{
throw new NotImplementedException("Our bar does not allow to modify a menu! (yet)");
if(item.Id != id) return BadRequest();
if(!ModelState.IsValid) return BadRequest(ModelState);
if (string.IsNullOrWhiteSpace(item.Name)) return BadRequest("Item name is Null or contain only WhiteSpace");
if (item.Price <= 0) return BadRequest("Item price must be above zero");
bool isUpdate = await _menuRepository.Update(item);
if(isUpdate)
{
return new NoContentResult();
}
else
{
return BadRequest();
}
}

// DELETE api/<MenuController>/name
[HttpDelete("{name}")]
public async Task Delete(string name)
// DELETE api/<MenuController>/id
[HttpDelete("{id}")]
[ProducesResponseType(204)]
[ProducesResponseType(404)]
public async Task<IActionResult> Delete(int id)
{
await _menuRepository.Remove(name);
var exist = await _menuRepository.GetItem(id);
if(exist == null) return NotFound();
bool isDelete = await _menuRepository.Remove(id);
if (isDelete)
{
return new NoContentResult();
Comment thread
AshasTob marked this conversation as resolved.
}
else
{
return BadRequest($"Item with id = {id} was found but faild to delete");
}
}
}
}
57 changes: 57 additions & 0 deletions BarAPI/Controllers/OrderController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using DataAccess.Data;
using DataAccess.Repository;

namespace BarAPI.Controllers
{
[Route("api/[controller]")]
[ApiController]
public class OrderController : Controller
Comment thread
AshasTob marked this conversation as resolved.
{
private readonly IOrderRepository _orderRepository;

public OrderController(IOrderRepository orderRepository)
{
_orderRepository = orderRepository;
}

// GET: api/<OrderController>/id
[HttpGet("{id}")]
[ProducesResponseType(200, Type = typeof(Order))]
[ProducesResponseType(404)]
public async Task<IActionResult> Get(int id)
{
Order order = await _orderRepository.Get(id);
if(order == null)
{
return NotFound();
}
else
{
return Ok(order);
}
}

// POST: api/<OrderController>/
[HttpPost]
[ProducesResponseType(200, Type = typeof(Order))]
[ProducesResponseType(400)]
public async Task<IActionResult> Upsert([FromBody] Order item)
{
if (!ModelState.IsValid) return BadRequest(ModelState);
bool isUpsert = await _orderRepository.Upsert(item);
if (isUpsert)
{
return Ok(item);
}
else
{
return BadRequest();
}
}
}
}
53 changes: 0 additions & 53 deletions BarAPI/DataAccess/InMemoryRepository.cs

This file was deleted.

Loading