Browse Source

removed obsolete DTOs

Amedeo
nek0 2 years ago
parent
commit
f970ccc07e
  1. 15
      Controllers/LendController.cs
  2. 9
      DTOs/ItemRead.cs
  3. 11
      DTOs/LendRead.cs
  4. 1
      Models/Item.cs
  5. 2
      Models/Lend.cs
  6. 2
      Models/LendModel.cs

15
Controllers/LendController.cs

@ -34,21 +34,8 @@ namespace BuecherwurmAPI.Controllers
//POST api/leihvorgang
[HttpPost]
public ActionResult<LendReadDTO> LendsPost(LendSeed lend)
public ActionResult<LendPost> LendsPost(LendPost lend)
{
/*
Internally a lend is stored with an id
but the client shouldn't be allowed to set or change it
therefore the package 'AutoMapper' is used to prevent errors
that could happen when doing this task manually.
It takes the information from the client and maps it to the
corresponding internal object which then will be returned.
Furthermore it could be used to keep some attributes secret.
Another nice effect of this is that the implementation could be changed
while the interface could be retained by some minor changes in the code.
DTO stands for Data Transfer Object
*/
var newId = _repository.insertLendReturningId(lend);
if (newId > 0)
{

9
DTOs/ItemRead.cs

@ -1,9 +0,0 @@
using System;
namespace BuecherwurmAPI.DTOs
{
public class ItemReadDTO
{
public int BookId { get; set;}
}
}

11
DTOs/LendRead.cs

@ -1,11 +0,0 @@
using System;
namespace BuecherwurmAPI.DTOs
{
public class LendReadDTO
{
public int ItemId { get; set;}
public DateTime ReturnDate { get; set; }
public string Customer { get; set; }
}
}

1
Models/Item.cs

@ -13,5 +13,4 @@ namespace BuecherwurmAPI.Models
{
public int BookId { get; set; }
}
}

2
Models/Lend.cs

@ -17,7 +17,7 @@ namespace BuecherwurmAPI.Models
public bool Returned { get; set; }
}
public class LendSeed
public class LendPost
{
public long ItemId {get; set;}

2
Models/LendModel.cs

@ -95,7 +95,7 @@ namespace BuecherwurmAPI.Models
return null;
}
public long insertLendReturningId(LendSeed lend)
public long insertLendReturningId(LendPost lend)
{
using (var command = _dbConnection.CreateCommand())
{

Loading…
Cancel
Save