всё, я дома

This commit is contained in:
antoc0der 2024-05-26 11:53:10 +04:00
parent f540dc8353
commit 09d9cebef1
7 changed files with 21 additions and 8 deletions

View File

@ -15,6 +15,8 @@ namespace VeterinaryContracts.ViewModels
public string ServiceName { get; set; } = string.Empty;
public int VisitId { get; set; }
public int DoctorId { get; set; }
[DisplayName("Посещение")]
public string VisitName { get; set; } = string.Empty;
public Dictionary<int, IMedicationModel> ServiceMedications
{
get;

View File

@ -79,9 +79,10 @@ namespace VeterinaryDatabaseImplement.Implements
return null;
}
drug.UpdateMedications(context, model);
drug.UpdateMedications(context, model); // работает
context.SaveChanges();
drug.Update(context,model);// не работает сумма
context.SaveChanges();
drug.Update(context,model);
transaction.Commit();
return drug.GetViewModel;
}

View File

@ -68,19 +68,20 @@ namespace VeterinaryDatabaseImplement.Models
DateCreate= model.DateCreate
};
}
// цену считает неверно
public void Update(VeterinaryDatabase context, DrugBindingModel model)
{
var justMedications = model.DrugMedications.Select(x => new DrugMedication
{
Medication = context.Medications.First(y => y.Id == x.Key)
}).ToList();
double prc = 0;
double pric = 0;
foreach (var justMedication in justMedications)
{
prc += justMedication.Medication.Price;
pric += justMedication.Medication.Price;
}
DrugName = model.DrugName;
Price = prc;
Price = pric;
}
public DrugViewModel GetViewModel => new()
{

View File

@ -65,6 +65,8 @@ namespace VeterinaryDatabaseImplement.Models
ServiceName = ServiceName,
DoctorId = DoctorId,
VisitId = VisitId,
VisitName = Visit?.VisitName ?? string.Empty,
};
public void UpdateMedications(VeterinaryDatabase context, ServiceBindingModel model)

View File

@ -5,6 +5,9 @@ using VeterinaryContracts.StorageContracts;
using VeterinaryDatabaseImplement.Implements;
using Microsoft.OpenApi.Models;
using VeterinaryBusinessLogic.MailWorker;
using VeterinaryBusinessLogic.OfficePackage;
using VeterinaryBusinessLogic.OfficePackage.Implements;
var builder = WebApplication.CreateBuilder(args);
@ -27,6 +30,11 @@ builder.Services.AddTransient<IOwnerLogic, OwnerLogic>();
builder.Services.AddTransient<IServiceLogic, ServiceLogic>();
builder.Services.AddTransient<IMedicationLogic, MedicationLogic>();
builder.Services.AddTransient<IPurchaseLogic, PurchaseLogic>();
builder.Services.AddTransient<IReportLogicDoctor, ReportLogicDoctor>();
builder.Services.AddTransient<AbstractSaveToExcelDoctor, SaveToExcelDoctor>();
builder.Services.AddTransient<AbstractSaveToWordDoctor, SaveToWordDoctor>();
builder.Services.AddTransient<AbstractSaveToPdfDoctor, SaveToPdfDoctor>();
builder.Services.AddSingleton<AbstractMailWorker, MailKitWorker>();
builder.Services.AddControllers();
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle

View File

@ -293,7 +293,6 @@ namespace VeterinaryShowDoctorApp.Controllers
{
throw new Exception("Вы как суда попали? Суда вход только авторизованным");
}
double _price=0;
if (string.IsNullOrEmpty(name) || count <= 0)
{
throw new Exception("Ошибка в введенных данных");
@ -405,7 +404,7 @@ namespace VeterinaryShowDoctorApp.Controllers
return Redirect("~/Home/Enter");
}
ViewBag.Services = APIDoctor.GetRequest<List<ServiceViewModel>>($"api/service/getservices?doctorid={APIDoctor.Doctor.Id}");
ViewBag.Medications = APIDoctor.GetRequest<List<MedicationViewModel>>($"api/medication/getmedications");
ViewBag.Medications = APIDoctor.GetRequest<List<MedicationViewModel>>($"api/medication/getmedications?doctorid={APIDoctor.Doctor.Id}");
return View();
}
// возможно нужно прописать визит айди

View File

@ -43,7 +43,7 @@
@Html.DisplayFor(modelItem =>item.ServiceName)
</td>
<td>
@Html.DisplayFor(modelItem =>item.VisitId)
@Html.DisplayFor(modelItem =>item.VisitName)
</td>
</tr>
}