SES-153 Add endpoint to create new Shopkeeper with items

This commit is contained in:
Karol Górzyński 2021-01-20 20:54:39 +01:00
parent 99f177887f
commit 42c786b1d0

View File

@ -5,6 +5,7 @@ using SessionCompanion.ViewModels.ApiResponses;
using SessionCompanion.ViewModels.ShopkeeperViewModels; using SessionCompanion.ViewModels.ShopkeeperViewModels;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
@ -29,5 +30,13 @@ namespace SessionCompanion.Controllers
{ {
return _service.Get().ToList(); return _service.Get().ToList();
} }
[HttpPost("createNewShopkeeper")]
public async Task<Either<SuccessResponse, ErrorResponse>> CreateNewShopKeeper([Required] ShopkeeperWithItemsViewModel shopkeeperWithItemsViewModel)
{
if (!ModelState.IsValid)
return new ErrorResponse() { StatusCode = 500, Message = "Model is invalid" };
return await _service.CreateNewShopKeeper(shopkeeperWithItemsViewModel);
}
} }
} }