поручитель. Чо?
This commit is contained in:
parent
47f06fcd3a
commit
4ad498b028
@ -47,6 +47,21 @@ namespace VeterinaryRestApi.Controllers
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public List<VisitViewModel> GetAllVisits()
|
||||
{
|
||||
try
|
||||
{
|
||||
return _visit.ReadList(null);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка получения списка визитов");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public bool CreateVisit(VisitBindingModel model)
|
||||
{
|
||||
|
@ -3,7 +3,6 @@ using System.Text;
|
||||
using VeterinaryContracts.ViewModels;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
|
||||
namespace VeterinaryShowDoctorApp
|
||||
{
|
||||
public static class APIDoctor
|
||||
@ -33,8 +32,7 @@ namespace VeterinaryShowDoctorApp
|
||||
public static void PostRequest<T>(string requestUrl, T model)
|
||||
{
|
||||
var json = JsonConvert.SerializeObject(model);
|
||||
var data = new StringContent(json, Encoding.UTF8,
|
||||
"application/json");
|
||||
var data = new StringContent(json, Encoding.UTF8,"application/json");
|
||||
var response = _doctor.PostAsync(requestUrl, data);
|
||||
var result = response.Result.Content.ReadAsStringAsync().Result;
|
||||
if (!response.Result.IsSuccessStatusCode)
|
||||
|
@ -333,6 +333,7 @@ namespace VeterinaryShowDoctorApp.Controllers
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
ViewBag.Medications = APIDoctor.GetRequest<List<MedicationViewModel>>($"api/medication/getmedications");
|
||||
ViewBag.Visits = APIDoctor.GetRequest<List<VisitViewModel>>($"api/visit/getallvisits");
|
||||
|
||||
return View();
|
||||
}
|
||||
@ -439,5 +440,15 @@ namespace VeterinaryShowDoctorApp.Controllers
|
||||
{
|
||||
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
|
||||
}
|
||||
// визиты
|
||||
public IActionResult Visits()
|
||||
{
|
||||
if (APIDoctor.Doctor == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
return View(APIDoctor.GetRequest<List<VisitViewModel>>($"api/visit/getallvisits"));
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -1,6 +1,5 @@
|
||||
using VeterinaryShowDoctorApp;
|
||||
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
// Add services to the container.
|
||||
|
@ -15,7 +15,7 @@
|
||||
<div class="row">
|
||||
<div class="col-4">Визиты:</div>
|
||||
<div class="col-8">
|
||||
<select id="visit" name="visit" class="form-control" asp-items="@(new SelectList(@ViewBag.Visits, "Id", "VisitName"))"></select>
|
||||
<select id="visits" name="visits" class="form-control" asp-items="@(new SelectList(@ViewBag.Visits, "Id", "VisitName"))"></select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
@ -36,22 +36,3 @@
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<script>
|
||||
$('#visit').on('change', function () {
|
||||
check();
|
||||
});
|
||||
|
||||
function check() {
|
||||
var visit = $('#visit').val();
|
||||
if (visit) {
|
||||
$.ajax({
|
||||
method: "POST",
|
||||
url: "/Home/GetService",
|
||||
data: {visit: visit },
|
||||
success: function (result) {
|
||||
$("#sum").val(result);
|
||||
}
|
||||
});
|
||||
};
|
||||
}
|
||||
</script>
|
@ -7,18 +7,18 @@ namespace VeterinaryShowOwnerApp
|
||||
{
|
||||
public static class APIOwner
|
||||
{
|
||||
private static readonly HttpClient _client = new();
|
||||
private static readonly HttpClient _owner = new();
|
||||
public static OwnerViewModel? Owner { get; set; } = null;
|
||||
public static void Connect(IConfiguration configuration)
|
||||
{
|
||||
_client.BaseAddress = new Uri(configuration["IPAddress"]);
|
||||
_client.DefaultRequestHeaders.Accept.Clear();
|
||||
_client.DefaultRequestHeaders.Accept.Add(new
|
||||
_owner.BaseAddress = new Uri(configuration["IPAddress"]);
|
||||
_owner.DefaultRequestHeaders.Accept.Clear();
|
||||
_owner.DefaultRequestHeaders.Accept.Add(new
|
||||
MediaTypeWithQualityHeaderValue("application/json"));
|
||||
}
|
||||
public static T? GetRequest<T>(string requestUrl)
|
||||
{
|
||||
var response = _client.GetAsync(requestUrl);
|
||||
var response = _owner.GetAsync(requestUrl);
|
||||
var result = response.Result.Content.ReadAsStringAsync().Result;
|
||||
if (response.Result.IsSuccessStatusCode)
|
||||
{
|
||||
@ -33,7 +33,7 @@ namespace VeterinaryShowOwnerApp
|
||||
{
|
||||
var json = JsonConvert.SerializeObject(model);
|
||||
var data = new StringContent(json, Encoding.UTF8, "application/json");
|
||||
var response = _client.PostAsync(requestUrl, data);
|
||||
var response = _owner.PostAsync(requestUrl, data);
|
||||
var result = response.Result.Content.ReadAsStringAsync().Result;
|
||||
if (!response.Result.IsSuccessStatusCode)
|
||||
{
|
||||
|
@ -261,7 +261,7 @@ namespace VeterinaryShowOwnerApp.Controllers
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void DeleteDrug(int visit)
|
||||
public void DeleteVisit(int visit)
|
||||
{
|
||||
if (APIOwner.Owner == null)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user