Исполнитель: сделал метод даты
This commit is contained in:
parent
1700333bfb
commit
bbb29596c7
@ -58,7 +58,23 @@ namespace VeterinaryBusinessLogic.BusinessLogic
|
||||
}
|
||||
return true;
|
||||
}
|
||||
// dateImplement
|
||||
public bool ChangeDateImplement(PurchaseBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
var element = _purchaseStorage.GetElement(new PurchaseSearchModel { Id = model.Id });
|
||||
if (element == null)
|
||||
{
|
||||
_logger.LogWarning("Read operation failed");
|
||||
return false;
|
||||
}
|
||||
if(element.DateCreate > DateTime.Now)
|
||||
{
|
||||
_logger.LogWarning("DateImplement change operation failed");
|
||||
}
|
||||
model.DateImplement = DateTime.Now;
|
||||
_purchaseStorage.Update(model);
|
||||
return true;
|
||||
}
|
||||
private void CheckModel(PurchaseBindingModel model, bool withParams = true)
|
||||
{
|
||||
if (model == null)
|
||||
|
@ -10,7 +10,7 @@ namespace VeterinaryContracts.BindingModels
|
||||
public int Count { get; set; }
|
||||
public double Sum { get; set; }
|
||||
public DateTime DateCreate { get; set; }
|
||||
public DateTime DateImplement { get; set; }
|
||||
public DateTime? DateImplement { get; set; }
|
||||
public Dictionary<int, IPetModel> PurchasePet { get; set; } = new();
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ namespace VeterinaryContracts.BindingModels
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public int OwnerId { get; set; }
|
||||
public int? DoctorId { get; set; } = null;
|
||||
public int DoctorId { get; set; }
|
||||
public string VisitName { get; set; } = string.Empty;
|
||||
public DateTime DateVisit { get; set; }
|
||||
public Dictionary<int, IPetModel> VisitPet { get; set; } = new();
|
||||
|
@ -9,5 +9,6 @@ namespace VeterinaryContracts.BusinessLogicContracts
|
||||
List<PurchaseViewModel>? ReadList(PurchaseSearchModel? model);
|
||||
PurchaseViewModel? ReadElement(PurchaseSearchModel model);
|
||||
bool CreatePurchase(PurchaseBindingModel model);
|
||||
bool ChangeDateImplement(PurchaseBindingModel model);
|
||||
}
|
||||
}
|
||||
|
@ -7,7 +7,7 @@
|
||||
int Count { get; }
|
||||
double Sum { get; }
|
||||
DateTime DateCreate { get; }
|
||||
DateTime DateImplement { get; }
|
||||
DateTime? DateImplement { get; }
|
||||
Dictionary<int, IPetModel> PurchasePet { get; }
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,7 @@
|
||||
public interface IVisitModel : IId
|
||||
{
|
||||
int OwnerId { get; }
|
||||
int? DoctorId { get; }
|
||||
int DoctorId { get; }
|
||||
string VisitName { get; }
|
||||
DateTime DateVisit { get; }
|
||||
Dictionary<int, IPetModel> VisitPet { get; }
|
||||
|
@ -3,6 +3,7 @@ using VeterinaryContracts.BindingModels;
|
||||
using VeterinaryContracts.BusinessLogicContracts;
|
||||
using VeterinaryContracts.SearchModels;
|
||||
using VeterinaryContracts.ViewModels;
|
||||
using VeterinaryDatabaseImplement.Models;
|
||||
|
||||
namespace VeterinaryRestApi.Controllers
|
||||
{
|
||||
@ -59,5 +60,19 @@ namespace VeterinaryRestApi.Controllers
|
||||
throw;
|
||||
}
|
||||
}
|
||||
[HttpPost]
|
||||
public bool ChangeDateImplement(PurchaseBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
_purchase.ChangeDateImplement(model);
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Не удалось обновить покупку");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -39,6 +39,7 @@
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<select id="purchases" name="purchases" class="form-control" asp-items="@(new SelectList(@ViewBag.Purchases, "Id"))">
|
||||
<tbody>
|
||||
@foreach (var item in Model)
|
||||
{
|
||||
@ -70,6 +71,7 @@
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</select>
|
||||
</table>
|
||||
}
|
||||
</div>
|
||||
|
Loading…
x
Reference in New Issue
Block a user