diff --git a/Uriagekun/Controllers/GoodsController.cs b/Uriagekun/Controllers/GoodsController.cs index df429fc..b995534 100644 --- a/Uriagekun/Controllers/GoodsController.cs +++ b/Uriagekun/Controllers/GoodsController.cs @@ -28,13 +28,12 @@ public class GoodsController : Controller if ( string.IsNullOrEmpty(model.Barcode) || model.Barcode.Length > 16 || string.IsNullOrEmpty(model.Label) || model.Label.Length > 40 - || model.Price < 0 ) { return BadRequest(); } - await this.repository.AddGoods(model.Label, model.Barcode, model.Price).ConfigureAwait(false); + await this.repository.AddGoods(model.Label, model.Barcode).ConfigureAwait(false); return RedirectToAction("Index"); } diff --git a/Uriagekun/Controllers/RecordController.cs b/Uriagekun/Controllers/RecordController.cs index 587e4b0..1f3b6f8 100644 --- a/Uriagekun/Controllers/RecordController.cs +++ b/Uriagekun/Controllers/RecordController.cs @@ -28,6 +28,7 @@ public class RecordController : Controller if ( string.IsNullOrEmpty(model.Barcode) || model.Barcode.Length > 16 || model.Count < 0 + || model.Price < 0 ) { return BadRequest(); @@ -44,7 +45,7 @@ public class RecordController : Controller int month = from.Month; int day = from.Day; var date = new DateTime(year, month, day); - await this.repository.AddRegister(good.Id, model.Count, date).ConfigureAwait(false); + await this.repository.AddRegister(good.Id, model.Count, model.Price, date).ConfigureAwait(false); return RedirectToAction("Register"); } diff --git a/Uriagekun/Lib/Data/GoodData.cs b/Uriagekun/Lib/Data/GoodData.cs index f40c124..b17cce5 100644 --- a/Uriagekun/Lib/Data/GoodData.cs +++ b/Uriagekun/Lib/Data/GoodData.cs @@ -14,7 +14,4 @@ public class GoodData [Column(Name = "label"), StringLength(40)] public string Label { get; set; } - - [Column(Name = "price")] - public int Price { get; set; } } diff --git a/Uriagekun/Lib/Data/GoodRegisterData.cs b/Uriagekun/Lib/Data/GoodRegisterData.cs index f00c869..3a359a8 100644 --- a/Uriagekun/Lib/Data/GoodRegisterData.cs +++ b/Uriagekun/Lib/Data/GoodRegisterData.cs @@ -16,6 +16,9 @@ public class GoodRegisterData [Column(Name = "date")] public DateTime Date { get; set; } + [Column(Name = "price")] + public int Price { get; set; } + [Column(Name = "count")] public int Count { get; set; } } diff --git a/Uriagekun/Lib/Data/RegisterData.cs b/Uriagekun/Lib/Data/RegisterData.cs index 634546f..4eba3a3 100644 --- a/Uriagekun/Lib/Data/RegisterData.cs +++ b/Uriagekun/Lib/Data/RegisterData.cs @@ -14,6 +14,9 @@ public class RegisterData [Column(Name = "date")] public DateTime Date { get; set; } + [Column(Name = "price")] + public int Price { get; set; } + [Column(Name = "count")] public int Count { get; set; } } diff --git a/Uriagekun/Lib/IO/MyRepository.cs b/Uriagekun/Lib/IO/MyRepository.cs index f395eba..cea5b85 100644 --- a/Uriagekun/Lib/IO/MyRepository.cs +++ b/Uriagekun/Lib/IO/MyRepository.cs @@ -17,15 +17,13 @@ public class MyRepository /// /// /// - /// /// 正常終了時、商品IDを返します。 - public async ValueTask AddGoods(string label, string barcode, int price) + public async ValueTask AddGoods(string label, string barcode) { GoodData data = new GoodData() { Label = label, Barcode = barcode, - Price = price, }; var ret = await this.database.InsertAsync(data).ConfigureAwait(false); @@ -74,13 +72,14 @@ public class MyRepository /// /// /// - public async ValueTask AddRegister(int goodId, int count, DateTime date) + public async ValueTask AddRegister(int goodId, int count, int price, DateTime date) { RegisterData data = new RegisterData() { GoodId = goodId, Date = date, Count = count, + Price = price, }; await this.database.InsertAsync(data).ConfigureAwait(false); @@ -89,7 +88,7 @@ public class MyRepository public async ValueTask> GetGoodRegisterFromBarcode(string barcode) { var ret = await this.database.FetchAsync( - $"SELECT goods.good_id, goods.barcode, goods.label, registers.date, registers.count FROM goods, registers WHERE barcode = {barcode} AND goods.good_id = registers.good_id" + $"SELECT goods.good_id, goods.barcode, goods.label, registers.date, registers.price, registers.count FROM goods, registers WHERE barcode = {barcode} AND goods.good_id = registers.good_id" ).ConfigureAwait(false); return ret; diff --git a/Uriagekun/Models/AddGoodModel.cs b/Uriagekun/Models/AddGoodModel.cs index 16c3237..ccb8741 100644 --- a/Uriagekun/Models/AddGoodModel.cs +++ b/Uriagekun/Models/AddGoodModel.cs @@ -9,7 +9,4 @@ public class AddGoodModel [Required] public string Label { get; set; } - - [Required] - public int Price { get; set; } } diff --git a/Uriagekun/Models/AddUriageModel.cs b/Uriagekun/Models/AddUriageModel.cs index db7dec6..1901331 100644 --- a/Uriagekun/Models/AddUriageModel.cs +++ b/Uriagekun/Models/AddUriageModel.cs @@ -7,6 +7,9 @@ public class AddUriageModel [Required] public string Barcode { get; set; } + [Required] + public int Price { get; set; } + [Required] public int Count { get; set; } } diff --git a/Uriagekun/Views/Goods/Index.cshtml b/Uriagekun/Views/Goods/Index.cshtml index 6225d7b..3e01a11 100644 --- a/Uriagekun/Views/Goods/Index.cshtml +++ b/Uriagekun/Views/Goods/Index.cshtml @@ -22,14 +22,6 @@ -
-
- -
-
- -
-
diff --git a/Uriagekun/Views/Record/Register.cshtml b/Uriagekun/Views/Record/Register.cshtml index f2721ad..f0e9a9a 100644 --- a/Uriagekun/Views/Record/Register.cshtml +++ b/Uriagekun/Views/Record/Register.cshtml @@ -12,6 +12,14 @@
+
+
+ +
+
+ +
+