Compare commits

..

No commits in common. "f3652285b9026469e96800fecd25b5bb267d4244" and "2bfd9748d9bf244f7335ccfe476d1144e20fff11" have entirely different histories.

46 changed files with 68 additions and 2027 deletions

View File

@ -17,7 +17,6 @@ namespace CaseAccountingContracts.ViewModels
[DisplayName("Номер дела")]
public int CaseId { get; set; }
public int UserId { get; set; }
[DisplayName("Номер слушания")]
public int Id { get; set; }
}
}

View File

@ -37,7 +37,7 @@ namespace CaseAccountingCustomerView.Controllers
{
throw new Exception("Введите логин и пароль");
}
APIUser.User = APIUser.GetRequest<UserViewModel>($"api/user/login?login={login}&password={password}&role={Role.Customer}");
APIUser.User = APIUser.GetRequest<UserViewModel>($"api/user/login?login={login}&password={password}&role={Role.Provider}");
if (APIUser.User == null)
{
throw new Exception("Неверный логин/пароль");
@ -56,7 +56,7 @@ namespace CaseAccountingCustomerView.Controllers
{
Login = login,
Password = password,
Role = Role.Customer
Role = Role.Provider
});
Response.Redirect("Login");
return;

View File

@ -18,8 +18,8 @@ namespace CaseAccountingDataBaseImplement
Host=localhost;
Port=5432;
Database=CaseAccountingDatabase;
Username=courseuser;
Password=courseuser");
Username=postgres;
Password=postgres");
}
base.OnConfiguring(optionsBuilder);
}

View File

@ -127,13 +127,14 @@ namespace CaseAccountingDataBaseImplement.Implements
public CaseViewModel? Insert(CaseBindingModel model)
{
using var context = new CaseAccountingDatabase();
var newCase = Case.Create(context, model);
var newCase = Case.Create(model);
if (newCase == null)
{
return null;
}
using var context = new CaseAccountingDatabase();
context.Cases.Add(newCase);
context.SaveChanges();
return context.Cases
@ -161,7 +162,6 @@ namespace CaseAccountingDataBaseImplement.Implements
_case.Update(model);
context.SaveChanges();
_case.UpdateLawyers(context, model);
transaction.Commit();
return _case.GetViewModel;
}
catch

View File

@ -119,7 +119,6 @@ namespace CaseAccountingDataBaseImplement.Implements
contract.Update(model);
context.SaveChanges();
contract.UpdateDeals(context, model);
transaction.Commit();
return contract.GetViewModel;
}
catch

View File

@ -86,13 +86,14 @@ namespace CaseAccountingDataBaseImplement.Implements
public DealViewModel? Insert(DealBindingModel model)
{
using var context = new CaseAccountingDatabase();
var newDeal = Deal.Create(context, model);
var newDeal = Deal.Create(model);
if (newDeal == null)
{
return null;
}
using var context = new CaseAccountingDatabase();
context.Deals.Add(newDeal);
context.SaveChanges();
return context.Deals
@ -118,7 +119,6 @@ namespace CaseAccountingDataBaseImplement.Implements
deal.Update(model);
context.SaveChanges();
deal.UpdateCases(context, model);
transaction.Commit();
return deal.GetViewModel;
}
catch

View File

@ -100,13 +100,14 @@ namespace CaseAccountingDataBaseImplement.Implements
public HearingViewModel? Insert(HearingBindingModel model)
{
using var context = new CaseAccountingDatabase();
var newHearing = Hearing.Create(context, model);
var newHearing = Hearing.Create(model);
if (newHearing == null)
{
return null;
}
using var context = new CaseAccountingDatabase();
context.Hearings.Add(newHearing);
context.SaveChanges();
return context.Hearings

View File

@ -126,7 +126,6 @@ namespace CaseAccountingDataBaseImplement.Implements
lawyer.Update(model);
context.SaveChanges();
lawyer.UpdateContracts(context, model);
transaction.Commit();
return lawyer.GetViewModel;
}
catch

View File

@ -18,6 +18,7 @@ namespace CaseAccountingDataBaseImplement.Implements
{
using var context = new CaseAccountingDatabase();
var element = context.Users
.Include(x => x.Role)
.FirstOrDefault(rec => rec.Id == model.Id);
if (element == null)
{
@ -30,12 +31,14 @@ namespace CaseAccountingDataBaseImplement.Implements
public UserViewModel? GetElement(UserSearchModel model)
{
if (!model.Id.HasValue)
{
return null;
}
using var context = new CaseAccountingDatabase();
return context.Users
.FirstOrDefault(x => (model.Id.HasValue && x.Id == model.Id) ||
(!string.IsNullOrEmpty(model.Login) && x.Login == model.Login &&
!string.IsNullOrEmpty(model.Password) && x.Password == model.Password &&
x.Role == model.Role))
.Include(x => x.Role)
.FirstOrDefault(x => model.Id.HasValue && x.Id == model.Id)
?.GetViewModel;
}
@ -45,6 +48,7 @@ namespace CaseAccountingDataBaseImplement.Implements
if (model.Id.HasValue)
{
return context.Users
.Include(x => x.Role)
.Where(x => x.Id == model.Id)
.Select(x => x.GetViewModel)
.ToList();
@ -59,6 +63,7 @@ namespace CaseAccountingDataBaseImplement.Implements
{
using var context = new CaseAccountingDatabase();
return context.Users
.Include(x => x.Role)
.Select(x => x.GetViewModel)
.ToList();
}
@ -76,6 +81,7 @@ namespace CaseAccountingDataBaseImplement.Implements
context.Users.Add(newUser);
context.SaveChanges();
return context.Users
.Include(x => x.Role)
.FirstOrDefault(x => x.Id == newUser.Id)
?.GetViewModel;
}
@ -85,6 +91,7 @@ namespace CaseAccountingDataBaseImplement.Implements
using var context = new CaseAccountingDatabase();
var user = context.Users
.Include(x => x.Role)
.FirstOrDefault(x => x.Id == model.Id);
if (user == null)
@ -94,6 +101,7 @@ namespace CaseAccountingDataBaseImplement.Implements
user.Update(model);
context.SaveChanges();
return context.Users
.Include(x => x.Role)
.FirstOrDefault(x => x.Id == model.Id)
?.GetViewModel;
}

View File

@ -1,553 +0,0 @@
// <auto-generated />
using System;
using CaseAccountingDataBaseImplement;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace CaseAccountingDataBaseImplement.Migrations
{
[DbContext(typeof(CaseAccountingDatabase))]
[Migration("20230518222251_MergMig")]
partial class MergMig
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "7.0.5")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Case", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Annotation")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Applicant")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("Date")
.HasColumnType("timestamp with time zone");
b.Property<string>("Defendant")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<int>("SpecializationId")
.HasColumnType("integer");
b.Property<int>("UserId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("SpecializationId");
b.HasIndex("UserId");
b.ToTable("Cases");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.CaseDeal", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("CaseId")
.HasColumnType("integer");
b.Property<int>("DealId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("CaseId");
b.HasIndex("DealId");
b.ToTable("CaseDeals");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.CaseLawyer", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("CaseId")
.HasColumnType("integer");
b.Property<int>("LawyerId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("CaseId");
b.HasIndex("LawyerId");
b.ToTable("CaseLawyers");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Contract", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<decimal>("Coast")
.HasColumnType("numeric");
b.Property<DateTime>("Date")
.HasColumnType("timestamp with time zone");
b.Property<string>("Service")
.IsRequired()
.HasColumnType("text");
b.Property<int>("UserId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("Contracts");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Deal", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<DateTime>("Date")
.HasColumnType("timestamp with time zone");
b.Property<string>("Responsibilities")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Subject")
.IsRequired()
.HasColumnType("text");
b.Property<int>("UserId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("Deals");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.DealContract", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("ContractId")
.HasColumnType("integer");
b.Property<int>("DealId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("ContractId");
b.HasIndex("DealId");
b.ToTable("DealContracts");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Hearing", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("CaseId")
.HasColumnType("integer");
b.Property<DateTime>("Date")
.HasColumnType("timestamp with time zone");
b.Property<string>("Information")
.IsRequired()
.HasColumnType("text");
b.Property<int>("UserId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("CaseId");
b.HasIndex("UserId");
b.ToTable("Hearings");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Lawyer", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("Experience")
.HasColumnType("integer");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Patronymic")
.IsRequired()
.HasColumnType("text");
b.Property<int>("SpecializationId")
.HasColumnType("integer");
b.Property<string>("Surname")
.IsRequired()
.HasColumnType("text");
b.Property<int>("UserId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("SpecializationId");
b.HasIndex("UserId");
b.ToTable("Lawyers");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.LawyerContract", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("ContractId")
.HasColumnType("integer");
b.Property<int>("LawyerId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("ContractId");
b.HasIndex("LawyerId");
b.ToTable("LawyerContracts");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Specialization", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<int>("UserId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("Specializations");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.User", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Login")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Password")
.IsRequired()
.HasColumnType("text");
b.Property<int>("Role")
.HasColumnType("integer");
b.HasKey("Id");
b.ToTable("Users");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Case", b =>
{
b.HasOne("CaseAccountingDataBaseImplement.Models.Specialization", "Specialization")
.WithMany("Cases")
.HasForeignKey("SpecializationId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("CaseAccountingDataBaseImplement.Models.User", "User")
.WithMany("Cases")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Specialization");
b.Navigation("User");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.CaseDeal", b =>
{
b.HasOne("CaseAccountingDataBaseImplement.Models.Case", "Case")
.WithMany("Deals")
.HasForeignKey("CaseId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("CaseAccountingDataBaseImplement.Models.Deal", "Deal")
.WithMany("CaseDeals")
.HasForeignKey("DealId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Case");
b.Navigation("Deal");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.CaseLawyer", b =>
{
b.HasOne("CaseAccountingDataBaseImplement.Models.Case", "Case")
.WithMany("CaseLawyers")
.HasForeignKey("CaseId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("CaseAccountingDataBaseImplement.Models.Lawyer", "Lawyer")
.WithMany("CaseLawyers")
.HasForeignKey("LawyerId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Case");
b.Navigation("Lawyer");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Contract", b =>
{
b.HasOne("CaseAccountingDataBaseImplement.Models.User", "User")
.WithMany("Contracts")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("User");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Deal", b =>
{
b.HasOne("CaseAccountingDataBaseImplement.Models.User", "User")
.WithMany("Deals")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("User");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.DealContract", b =>
{
b.HasOne("CaseAccountingDataBaseImplement.Models.Contract", "Contract")
.WithMany("DealContracts")
.HasForeignKey("ContractId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("CaseAccountingDataBaseImplement.Models.Deal", "Deal")
.WithMany("Contracts")
.HasForeignKey("DealId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Contract");
b.Navigation("Deal");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Hearing", b =>
{
b.HasOne("CaseAccountingDataBaseImplement.Models.Case", "Case")
.WithMany("Hearings")
.HasForeignKey("CaseId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("CaseAccountingDataBaseImplement.Models.User", "User")
.WithMany("Hearings")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Case");
b.Navigation("User");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Lawyer", b =>
{
b.HasOne("CaseAccountingDataBaseImplement.Models.Specialization", "Specialization")
.WithMany("Lawyers")
.HasForeignKey("SpecializationId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("CaseAccountingDataBaseImplement.Models.User", "User")
.WithMany("Lawyers")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Specialization");
b.Navigation("User");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.LawyerContract", b =>
{
b.HasOne("CaseAccountingDataBaseImplement.Models.Contract", "Contract")
.WithMany("LawyerContracts")
.HasForeignKey("ContractId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("CaseAccountingDataBaseImplement.Models.Lawyer", "Lawyer")
.WithMany("LawyerContracts")
.HasForeignKey("LawyerId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Contract");
b.Navigation("Lawyer");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Specialization", b =>
{
b.HasOne("CaseAccountingDataBaseImplement.Models.User", "User")
.WithMany("Specializations")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("User");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Case", b =>
{
b.Navigation("CaseLawyers");
b.Navigation("Deals");
b.Navigation("Hearings");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Contract", b =>
{
b.Navigation("DealContracts");
b.Navigation("LawyerContracts");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Deal", b =>
{
b.Navigation("CaseDeals");
b.Navigation("Contracts");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Lawyer", b =>
{
b.Navigation("CaseLawyers");
b.Navigation("LawyerContracts");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Specialization", b =>
{
b.Navigation("Cases");
b.Navigation("Lawyers");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.User", b =>
{
b.Navigation("Cases");
b.Navigation("Contracts");
b.Navigation("Deals");
b.Navigation("Hearings");
b.Navigation("Lawyers");
b.Navigation("Specializations");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -1,22 +0,0 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace CaseAccountingDataBaseImplement.Migrations
{
/// <inheritdoc />
public partial class MergMig : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
}
}
}

View File

@ -66,7 +66,7 @@ namespace CaseAccountingDataBaseImplement.Models
[ForeignKey("CaseId")]
public virtual List<CaseDeal> Deals { get; set; } = new();
public static Case? Create(CaseAccountingDatabase context, CaseBindingModel model)
public static Case? Create(CaseBindingModel model)
{
if (model == null)
{
@ -81,9 +81,7 @@ namespace CaseAccountingDataBaseImplement.Models
Annotation = model.Annotation,
Date = model.Date,
SpecializationId = model.SpecializationId,
Specialization = context.Specializations.FirstOrDefault( x => x.Id == model.SpecializationId) ?? throw new Exception("Specialization не существует"),
UserId = model.UserId,
User = context.Users.FirstOrDefault(x => x.Id == model.UserId) ?? throw new Exception("User не существует")
UserId = model.UserId
};
}

View File

@ -51,7 +51,7 @@ namespace CaseAccountingDataBaseImplement.Models
[ForeignKey("DealId")]
public virtual List<DealContract> Contracts { get; set; } = new();
public static Deal? Create(CaseAccountingDatabase context, DealBindingModel? model)
public static Deal? Create(DealBindingModel? model)
{
if (model == null)
{
@ -64,7 +64,6 @@ namespace CaseAccountingDataBaseImplement.Models
Responsibilities = model.Responsibilities,
Date = model.Date,
UserId = model.UserId,
User = context.Users.FirstOrDefault(x => x.Id == model.UserId) ?? throw new Exception("User не существует")
};
}

View File

@ -29,7 +29,7 @@ namespace CaseAccountingDataBaseImplement.Models
public int UserId { get; set; }
public virtual User User { get; set; } = new();
public static Hearing? Create (CaseAccountingDatabase context, HearingBindingModel? model)
public static Hearing? Create (HearingBindingModel? model)
{
if (model == null)
{
@ -41,9 +41,7 @@ namespace CaseAccountingDataBaseImplement.Models
Information = model.Information,
Date = model.Date,
CaseId = model.CaseId,
Case = context.Cases.FirstOrDefault(x => x.Id == model.CaseId) ?? throw new Exception("Case не существует"),
UserId = model.UserId,
User = context.Users.FirstOrDefault(x => x.Id == model.UserId) ?? throw new Exception("User не существует")
UserId = model.UserId
};
}

View File

@ -1,47 +0,0 @@
using CaseAccountingContracts.ViewModels;
using Newtonsoft.Json;
using System.Net.Http.Headers;
using System.Text;
namespace CaseAccountingProviderView
{
public static class APIUser
{
private static readonly HttpClient _user = new();
public static UserViewModel? User { get; set; } = null;
public static void Connect(IConfiguration configuration)
{
_user.BaseAddress = new Uri(configuration["IPAddress"]);
_user.DefaultRequestHeaders.Accept.Clear();
_user.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
}
public static T? GetRequest<T>(string requestUrl)
{
var response = _user.GetAsync(requestUrl);
var result = response.Result.Content.ReadAsStringAsync().Result;
if (response.Result.IsSuccessStatusCode)
{
return JsonConvert.DeserializeObject<T>(result);
}
else
{
throw new Exception(result);
}
}
public static void PostRequest<T>(string requestUrl, T model)
{
var json = JsonConvert.SerializeObject(model);
var data = new StringContent(json, Encoding.UTF8, "application/json");
var response = _user.PostAsync(requestUrl, data);
var result = response.Result.Content.ReadAsStringAsync().Result;
if (!response.Result.IsSuccessStatusCode)
{
throw new Exception(result);
}
}
}
}

View File

@ -6,17 +6,4 @@
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\CaseAccountingContracts\CaseAccountingContracts.csproj" />
</ItemGroup>
<ItemGroup>
<Folder Include="wwwroot\js\deal\" />
<Folder Include="wwwroot\js\hearing\" />
</ItemGroup>
</Project>

View File

@ -1,123 +0,0 @@
using CaseAccountingContracts.BindingModels;
using CaseAccountingContracts.ViewModels;
using Microsoft.AspNetCore.Mvc;
namespace CaseAccountingProviderView.Controllers
{
public class CaseController : Controller
{
public IActionResult Create()
{
if (APIUser.User == null)
{
return Redirect("~/Home/Enter");
}
return View();
}
[HttpPost]
public void Create([FromBody] CaseBindingModel caseModel)
{
if (APIUser.User == null)
{
throw new Exception("403");
}
caseModel.UserId = APIUser.User.Id;
APIUser.PostRequest("api/case/create", caseModel);
Response.Redirect("/Home/Cases");
}
public IActionResult Update(int id)
{
if (APIUser.User == null)
{
return Redirect("~/Home/Enter");
}
ViewBag.Case = APIUser.GetRequest<CaseViewModel>($"api/case/get?id={id}");
return View();
}
[HttpPost]
public void Update([FromBody] CaseBindingModel caseModel)
{
if (APIUser.User == null)
{
throw new Exception("403");
}
caseModel.UserId = APIUser.User.Id;
APIUser.PostRequest("api/case/update", caseModel);
Response.Redirect("/Home/Cases");
}
public IActionResult AddCase(int id)
{
if (APIUser.User == null)
{
return Redirect("~/Home/Enter");
}
ViewBag.CaseId = id;
return View();
}
[HttpPost]
public void AddCase([FromBody] CaseBindingModel caseModel)
{
if (APIUser.User == null)
{
throw new Exception("403");
}
APIUser.PostRequest("api/case/update", caseModel);
}
public IActionResult Bind(int id)
{
if (APIUser.User == null)
{
return Redirect("~/Home/Enter");
}
ViewBag.Case = APIUser.GetRequest<CaseViewModel>($"api/case/get?id={id}");
return View();
}
[HttpPost]
public void Bind([FromBody] CaseBindingModel caseModel)
{
if (APIUser.User == null)
{
throw new Exception("403");
}
APIUser.PostRequest("api/case/update", caseModel);
}
[HttpPost]
public void Delete(int id)
{
if (APIUser.User == null)
{
throw new Exception("403");
}
APIUser.PostRequest($"api/case/delete", new CaseBindingModel() { Id = id });
Response.Redirect("/Home/Cases");
}
public List<CaseViewModel> GetAllByUser()
{
if (APIUser.User == null)
{
return new();
}
List<CaseViewModel>? caseModel = APIUser.GetRequest<List<CaseViewModel>>($"api/case/getallbyuser?userId={APIUser.User.Id}");
return caseModel ?? new();
}
public CaseViewModel? Get(int id)
{
if (APIUser.User == null)
{
return new();
}
CaseViewModel? caseModel = APIUser.GetRequest<CaseViewModel>($"api/case/get?id={id}");
return caseModel;
}
}
}

View File

@ -1,123 +0,0 @@
using CaseAccountingContracts.BindingModels;
using CaseAccountingContracts.ViewModels;
using Microsoft.AspNetCore.Mvc;
namespace CaseAccountingProviderView.Controllers
{
public class DealController : Controller
{
public IActionResult Create()
{
if (APIUser.User == null)
{
return Redirect("~/Home/Enter");
}
return View();
}
[HttpPost]
public void Create([FromBody] DealBindingModel dealModel)
{
if (APIUser.User == null)
{
throw new Exception("403");
}
dealModel.UserId = APIUser.User.Id;
APIUser.PostRequest("api/deal/create", dealModel);
Response.Redirect("/Home/Deals");
}
public IActionResult Update(int id)
{
if (APIUser.User == null)
{
return Redirect("~/Home/Enter");
}
ViewBag.Deal = APIUser.GetRequest<DealViewModel>($"api/deal/get?id={id}");
return View();
}
[HttpPost]
public void Update([FromBody] DealBindingModel dealModel)
{
if (APIUser.User == null)
{
throw new Exception("403");
}
dealModel.UserId = APIUser.User.Id;
APIUser.PostRequest("api/deal/update", dealModel);
Response.Redirect("/Home/Deals");
}
public IActionResult AddDeal(int id)
{
if (APIUser.User == null)
{
return Redirect("~/Home/Enter");
}
ViewBag.DealId = id;
return View();
}
[HttpPost]
public void AddDeal([FromBody] DealBindingModel dealModel)
{
if (APIUser.User == null)
{
throw new Exception("403");
}
APIUser.PostRequest("api/deal/update", dealModel);
}
public IActionResult Bind(int id)
{
if (APIUser.User == null)
{
return Redirect("~/Home/Enter");
}
ViewBag.Deal = APIUser.GetRequest<DealViewModel>($"api/deal/get?id={id}");
return View();
}
[HttpPost]
public void Bind([FromBody] DealBindingModel dealModel)
{
if (APIUser.User == null)
{
throw new Exception("403");
}
APIUser.PostRequest("api/deal/update", dealModel);
}
[HttpPost]
public void Delete(int id)
{
if (APIUser.User == null)
{
throw new Exception("403");
}
APIUser.PostRequest($"api/deal/delete", new DealBindingModel() { Id = id });
Response.Redirect("/Home/Deals");
}
public List<DealViewModel> GetAllByUser()
{
if (APIUser.User == null)
{
return new();
}
List<DealViewModel>? dealModel = APIUser.GetRequest<List<DealViewModel>>($"api/deal/getallbyuser?userId={APIUser.User.Id}");
return dealModel ?? new();
}
public DealViewModel? Get(int id)
{
if (APIUser.User == null)
{
return new();
}
DealViewModel? dealModel = APIUser.GetRequest<DealViewModel>($"api/deal/get?id={id}");
return dealModel;
}
}
}

View File

@ -1,123 +0,0 @@
using CaseAccountingContracts.BindingModels;
using CaseAccountingContracts.ViewModels;
using Microsoft.AspNetCore.Mvc;
namespace CaseAccountingProviderView.Controllers
{
public class HearingController : Controller
{
public IActionResult Create()
{
if (APIUser.User == null)
{
return Redirect("~/Home/Enter");
}
return View();
}
[HttpPost]
public void Create([FromBody] HearingBindingModel hearingModel)
{
if (APIUser.User == null)
{
throw new Exception("403");
}
hearingModel.UserId = APIUser.User.Id;
APIUser.PostRequest("api/hearing/create", hearingModel);
Response.Redirect("/Home/Hearings");
}
public IActionResult Update(int id)
{
if (APIUser.User == null)
{
return Redirect("~/Home/Enter");
}
ViewBag.Hearing = APIUser.GetRequest<HearingViewModel>($"api/hearing/get?id={id}");
return View();
}
[HttpPost]
public void Update([FromBody] HearingBindingModel hearingModel)
{
if (APIUser.User == null)
{
throw new Exception("403");
}
hearingModel.UserId = APIUser.User.Id;
APIUser.PostRequest("api/hearing/update", hearingModel);
Response.Redirect("/Home/Hearings");
}
public IActionResult AddHearing(int id)
{
if (APIUser.User == null)
{
return Redirect("~/Home/Enter");
}
ViewBag.HearingId = id;
return View();
}
[HttpPost]
public void AddHearing([FromBody] HearingBindingModel hearingModel)
{
if (APIUser.User == null)
{
throw new Exception("403");
}
APIUser.PostRequest("api/hearing/update", hearingModel);
}
public IActionResult Bind(int id)
{
if (APIUser.User == null)
{
return Redirect("~/Home/Enter");
}
ViewBag.Hearing = APIUser.GetRequest<HearingViewModel>($"api/hearing/get?id={id}");
return View();
}
[HttpPost]
public void Bind([FromBody] HearingBindingModel hearingModel)
{
if (APIUser.User == null)
{
throw new Exception("403");
}
APIUser.PostRequest("api/hearing/update", hearingModel);
}
[HttpPost]
public void Delete(int id)
{
if (APIUser.User == null)
{
throw new Exception("403");
}
APIUser.PostRequest($"api/hearing/delete", new HearingBindingModel() { Id = id });
Response.Redirect("/Home/Hearings");
}
public List<HearingViewModel> GetAllByUser()
{
if (APIUser.User == null)
{
return new();
}
List<HearingViewModel>? hearingModel = APIUser.GetRequest<List<HearingViewModel>>($"api/hearing/getallbyuser?userId={APIUser.User.Id}");
return hearingModel ?? new();
}
public HearingViewModel? Get(int id)
{
if (APIUser.User == null)
{
return new();
}
HearingViewModel? hearingModel = APIUser.GetRequest<HearingViewModel>($"api/hearing/get?id={id}");
return hearingModel;
}
}
}

View File

@ -1,7 +1,4 @@
using CaseAccountingContracts.BindingModels;
using CaseAccountingContracts.ViewModels;
using CaseAccountingDataModels.Enum;
using CaseAccountingProviderView.Models;
using CaseAccountingProviderView.Models;
using Microsoft.AspNetCore.Mvc;
using System.Diagnostics;
@ -18,95 +15,14 @@ namespace CaseAccountingProviderView.Controllers
public IActionResult Index()
{
if (APIUser.User == null)
{
return Redirect("~/Home/Login");
}
return View();
}
public IActionResult Login()
public IActionResult Privacy()
{
return View();
}
public IActionResult Registration()
{
return View();
}
[HttpPost]
public void Login(string login, string password)
{
if (string.IsNullOrEmpty(login) || string.IsNullOrEmpty(password))
{
throw new Exception("Введите логин и пароль");
}
APIUser.User = APIUser.GetRequest<UserViewModel>($"api/user/login?login={login}&password={password}&role={Role.Provider}");
if (APIUser.User == null)
{
throw new Exception("Неверный логин/пароль");
}
Response.Redirect("Index");
}
[HttpPost]
public void Registration(string login, string password)
{
if (string.IsNullOrEmpty(login) || string.IsNullOrEmpty(password))
{
throw new Exception("Введите логин и пароль");
}
APIUser.PostRequest("api/user/register", new UserBindingModel
{
Login = login,
Password = password,
Role = Role.Provider
});
Response.Redirect("Login");
return;
}
public IActionResult Cases()
{
if (APIUser.User == null)
{
return Redirect("~/Home/Enter");
}
/*if (page == 0)
{
page = 1;
}*/
ViewBag.Cases = APIUser.GetRequest<List<CaseViewModel>>
($"api/case/getallbyuser?userId={APIUser.User.Id}");
/*ViewBag.Page = page;
ViewBag.NumberOfPages = APIUser.GetRequest<int>
($"api/student/getnumberofpages?userId={APIUser.User.Id}");*/
return View();
}
public IActionResult Deals()
{
if (APIUser.User == null)
{
return Redirect("~/Home/Enter");
}
ViewBag.Deals = APIUser.GetRequest<List<DealViewModel>>
($"api/deal/getallbyuser?userId={APIUser.User.Id}");
return View();
}
public IActionResult Hearings()
{
if (APIUser.User == null)
{
return Redirect("~/Home/Enter");
}
ViewBag.Hearings = APIUser.GetRequest<List<HearingViewModel>>
($"api/hearing/getallbyuser?userId={APIUser.User.Id}");
return View();
}
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
public IActionResult Error()
{

View File

@ -1,5 +1,3 @@
using CaseAccountingProviderView;
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
@ -7,8 +5,6 @@ builder.Services.AddControllersWithViews();
var app = builder.Build();
APIUser.Connect(builder.Configuration);
// Configure the HTTP request pipeline.
if (!app.Environment.IsDevelopment())
{

View File

@ -1,32 +0,0 @@
@{
ViewData["Title"] = "Дело";
}
<h4 class="fw-bold">Создание дела</h4>
<div id="error-div-shell" class="error-div-shell mb-2">
<div>
<p id="error-p" class="error-p"></p>
</div>
</div>
<p class="mb-0">Название:</p>
<input type="text" id="name-input" name="name" class="form-control mb-3" />
<p class="mb-0">Истец:</p>
<input type="text" id="applicant-input" name="applicant" class="form-control mb-3" />
<p class="mb-0">Ответчик:</p>
<input type="text" id="defendant-input" name="defendant" class="form-control mb-3" />
<p class="mb-0">Дата составления:</p>
<input type="date" id="date-input" name="date" class="form-control mb-3" />
<p class="mb-0">Примечание:</p>
<input type="text" id="annotation-input" name="annotation" class="form-control mb-3" />
<p class="mb-0">Специализация:</p>
<select id="specialization-select" name="specialization" class="form-control mb-3">
<option></option>
</select>
<button id="create-button" type="button" class="btn btn-primary text-button">
Создать
</button>
<script src="~/js/case/case-create.js" asp-append-version="true"></script>

View File

@ -1,43 +0,0 @@
@{
ViewData["Title"] = "Дело";
}
@{
<h4 class="fw-bold" id="vb-id" data-id="@ViewBag.Case.Id">Изменение дела</h4>
if (ViewBag.Case == null)
{
<h3 class="display-4">Войдите в аккаунт</h3>
return;
}
<div id="error-div-shell" class="error-div-shell mb-2">
<div>
<p id="error-p" class="error-p"></p>
</div>
</div>
<p class="mb-0">Название:</p>
<input type="text" id="name-input" name="name" class="form-control mb-3" />
<p class="mb-0">Истец:</p>
<input type="text" id="applicant-input" name="applicant" class="form-control mb-3" />
<p class="mb-0">Ответчик:</p>
<input type="text" id="defendant-input" name="defendant" class="form-control mb-3" />
<p class="mb-0">Дата составления:</p>
<input type="date" id="date-input" name="date" class="form-control mb-3" />
<p class="mb-0">Примечание:</p>
<input type="text" id="annotation-input" name="annotation" class="form-control mb-3" />
<p class="mb-0">Специализация:</p>
<select id="specialization-select" name="specialization" class="form-control mb-3">
<option></option>
</select>
<button id="update-button" type="button" class="btn btn-primary text-button">
Обновить
</button>
}
<script src="~/js/case/case-update.js" asp-append-version="true"></script>

View File

@ -1,24 +0,0 @@
@{
ViewData["Title"] = "Договор";
}
<h4 class="fw-bold">Создание договора</h4>
<div id="error-div-shell" class="error-div-shell mb-2">
<div>
<p id="error-p" class="error-p"></p>
</div>
</div>
<p class="mb-0">Объект договора:</p>
<input type="text" id="subject-input" name="subject" class="form-control mb-3" />
<p class="mb-0">Обязаности:</p>
<input type="text" id="responsibilities-input" name="responsibilities" class="form-control mb-3" />
<p class="mb-0">Дата составления:</p>
<input type="date" id="date-input" name="date" class="form-control mb-3" />
<button id="create-button" type="button" class="btn btn-primary text-button">
Создать
</button>
<script src="~/js/deal/deal-create.js" asp-append-version="true"></script>

View File

@ -1,34 +0,0 @@
@{
ViewData["Title"] = "Договор";
}
@{
<h4 class="fw-bold" id="vb-id" data-id="@ViewBag.Deal.Id">Изменение договора</h4>
if (ViewBag.Deal == null)
{
<h3 class="display-4">Войдите в аккаунт</h3>
return;
}
<div id="error-div-shell" class="error-div-shell mb-2">
<div>
<p id="error-p" class="error-p"></p>
</div>
</div>
<p class="mb-0">Объект договора:</p>
<input type="text" id="subject-input" name="subject" class="form-control mb-3" />
<p class="mb-0">Обязаности:</p>
<input type="text" id="responsibilities-input" name="responsibilities" class="form-control mb-3" />
<p class="mb-0">Дата составления:</p>
<input type="date" id="date-input" name="date" class="form-control mb-3" />
<button id="update-button" type="button" class="btn btn-primary text-button">
Обновить
</button>
}
<script src="~/js/deal/deal-update.js" asp-append-version="true"></script>

View File

@ -1,26 +0,0 @@
@{
ViewData["Title"] = "Слушание";
}
<h4 class="fw-bold">Создание слушания</h4>
<div id="error-div-shell" class="error-div-shell mb-2">
<div>
<p id="error-p" class="error-p"></p>
</div>
</div>
<p class="mb-0">Информация по слушанию:</p>
<input type="text" id="information-input" name="information" class="form-control mb-3" />
<p class="mb-0">Дата проведения:</p>
<input type="date" id="date-input" name="date" class="form-control mb-3" />
<p class="mb-0">Дело:</p>
<select id="case-select" name="case" class="form-control mb-3">
<option></option>
</select>
<button id="create-button" type="button" class="btn btn-primary text-button">
Создать
</button>
<script src="~/js/hearing/hearing-create.js" asp-append-version="true"></script>

View File

@ -1,36 +0,0 @@
@{
ViewData["Title"] = "Слушание";
}
@{
<h4 class="fw-bold" id="vb-id" data-id="@ViewBag.Hearing.Id">Изменение слушания</h4>
if (ViewBag.Hearing == null)
{
<h3 class="display-4">Войдите в аккаунт</h3>
return;
}
<div id="error-div-shell" class="error-div-shell mb-2">
<div>
<p id="error-p" class="error-p"></p>
</div>
</div>
<p class="mb-0">Информация по слушанию:</p>
<input type="text" id="information-input" name="information" class="form-control mb-3" />
<p class="mb-0">Дата проведения:</p>
<input type="date" id="date-input" name="date" class="form-control mb-3" />
<p class="mb-0">Дело:</p>
<select id="case-select" name="case" class="form-control mb-3">
<option></option>
</select>
<button id="update-button" type="button" class="btn btn-primary text-button">
Обновить
</button>
}
<script src="~/js/hearing/hearing-update.js" asp-append-version="true"></script>

View File

@ -1,89 +0,0 @@
@{
ViewData["Title"] = "Дела";
}
<div class="text-center">
<h1 class="display-4">Дела</h1>
</div>
<div class="text-center">
@{
if (ViewBag.Cases == null)
{
<h3 class="display-4">Войдите в аккаунт</h3>
return;
}
<div>
<a class="btn btn-success" asp-controller="Case" asp-action="Create">Создать запись</a>
</div>
<table class="table">
<thead>
<tr>
<th>
Номер Дела
</th>
<th>
Название
</th>
<th>
Истец
</th>
<th>
Ответчик
</th>
<th>
Примечание
</th>
<th>
Дата оформления
</th>
<th>
Специализация
</th>
<th>
Изменить запись
</th>
<th>
Удалить запись
</th>
</tr>
</thead>
<tbody>
@foreach (var item in ViewBag.Cases)
{
<tr class="d-table-row">
<td>
@item.Id
</td>
<td>
@item.Name
</td>
<td>
@item.Applicant
</td>
<td>
@item.Defendant
</td>
<td>
@item.Annotation
</td>
<td>
@item.Date.ToString("yyyy-MM-dd")
</td>
<td>
@item.Specialization
</td>
<td>
<a id="update-button-@item.Id" class="btn btn-warning" asp-controller="Case" asp-action="Update" asp-route-id="@item.Id">Изменить</a>
</td>
<td>
<a id="remove-button-@item.Id" class="btn btn-danger remove-btn" data-id="@item.Id">Удалить</a>
</td>
</tr>
}
</tbody>
</table>
}
</div>
<script src="~/js/case/cases.js" asp-append-version="true"></script>

View File

@ -1,65 +0,0 @@
@{
ViewData["Title"] = "Договора";
}
<div class="text-center">
<h1 class="display-4">Договора</h1>
</div>
<div class="text-center">
@{
if (ViewBag.Deals == null)
{
<h3 class="display-4">Войдите в аккаунт</h3>
return;
}
<div>
<a class="btn btn-success" asp-controller="Deal" asp-action="Create">Создать запись</a>
</div>
<table class="table">
<thead>
<tr>
<th>
Предмет договора
</th>
<th>
Обязанности
</th>
<th>
Дата составления
</th>
<th>
Изменить запись
</th>
<th>
Удалить запись
</th>
</tr>
</thead>
<tbody>
@foreach (var item in ViewBag.Deals)
{
<tr class="d-table-row">
<td>
@item.Subject
</td>
<td>
@item.Responsibilities
</td>
<td>
@item.Date.ToString("yyyy-MM-dd")
</td>
<td>
<a id="update-button-@item.Id" class="btn btn-warning" asp-controller="Deal" asp-action="Update" asp-route-id="@item.Id">Изменить</a>
</td>
<td>
<a id="remove-button-@item.Id" class="btn btn-danger remove-btn" data-id="@item.Id">Удалить</a>
</td>
</tr>
}
</tbody>
</table>
}
</div>
<script src="~/js/deal/deals.js" asp-append-version="true"></script>

View File

@ -1,71 +0,0 @@
@{
ViewData["Title"] = "Слушания";
}
<div class="text-center">
<h1 class="display-4">Слушания</h1>
</div>
<div class="text-center">
@{
if (ViewBag.Hearings == null)
{
<h3 class="display-4">Войдите в аккаунт</h3>
return;
}
<div>
<a class="btn btn-success" asp-controller="Hearing" asp-action="Create">Создать запись</a>
</div>
<table class="table">
<thead>
<tr>
<th>
Номер
</th>
<th>
Информация
</th>
<th>
Номер Дела
</th>
<th>
Дата слушания
</th>
<th>
Изменить запись
</th>
<th>
Удалить запись
</th>
</tr>
</thead>
<tbody>
@foreach (var item in ViewBag.Hearings)
{
<tr class="d-table-row">
<td>
@item.Id
</td>
<td>
@item.Information
</td>
<td>
@item.CaseId
</td>
<td>
@item.Date.ToString("yyyy-MM-dd")
</td>
<td>
<a id="update-button-@item.Id" class="btn btn-warning" asp-controller="Hearing" asp-action="Update" asp-route-id="@item.Id">Изменить</a>
</td>
<td>
<a id="remove-button-@item.Id" class="btn btn-danger remove-btn" data-id="@item.Id">Удалить</a>
</td>
</tr>
}
</tbody>
</table>
}
</div>
<script src="~/js/hearing/hearings.js" asp-append-version="true"></script>

View File

@ -1,7 +1,8 @@
@{
ViewData["Title"] = "Домашняя сраница";
ViewData["Title"] = "Home Page";
}
<div class="text-center">
<h1>Добро пожаловать в курсовую работу!!!</h1>
<h1 class="display-4">Welcome</h1>
<p>Learn about <a href="https://docs.microsoft.com/aspnet/core">building Web apps with ASP.NET Core</a>.</p>
</div>

View File

@ -1,27 +0,0 @@
@{
ViewData["Title"] = "Вход";
}
<div class="text-center">
<h2 class="display-4">Вход в приложение</h2>
</div>
<form method="post">
<div class="row">
<div class="col-4">Логин:</div>
<div class="col-8"><input type="text" name="login" /></div>
</div>
<div class="row">
<div class="col-4">Пароль:</div>
<div class="col-8"><input type="password" name="password" /></div>
</div>
<div class="row">
<div class="col-8">
<a class="nav-link text-primary" asp-area="" asp-controller="Home" asp-action="Registration">
Нет аккаунта?
</a>
</div>
<div class="col-4">
<input type="submit" value="Войти" class="btn btn-info" />
</div>
</div>
</form>

View File

@ -0,0 +1,6 @@
@{
ViewData["Title"] = "Privacy Policy";
}
<h1>@ViewData["Title"]</h1>
<p>Use this page to detail your site's privacy policy.</p>

View File

@ -1,27 +0,0 @@
@{
ViewData["Title"] = "Регистрация";
}
<div class="text-center">
<h2 class="display-4">Регистрация</h2>
</div>
<form method="post">
<div class="row">
<div class="col-4">Логин (эл.почта):</div>
<div class="col-8"><input type="email" name="login" /></div>
</div>
<div class="row">
<div class="col-4">Пароль:</div>
<div class="col-8"><input type="password" name="password" /></div>
</div>
<div class="row">
<div class="col-8">
<a class="nav-link text-primary" asp-area="" asp-controller="Home" asp-action="Login">
Есть аккаунт?
</a>
</div>
<div class="col-4">
<input type="submit" value="Регистрация" class="btn btn-info" />
</div>
</div>
</form>

View File

@ -1,5 +1,5 @@
<!DOCTYPE html>
<html lang="ru">
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
@ -10,18 +10,22 @@
</head>
<body>
<header>
<nav class="navbar navbar-expand-lg bg-body-tertiary bg-primary" data-bs-theme="dark">
<div class="container">
<a class="navbar-brand text-white" asp-area="" asp-controller="Home" aspaction="Index">Юридическая фирма "Вас обманут"</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNavAltMarkup" aria-controls="navbarNavAltMarkup" aria-expanded="false" aria-label="Toggle navigation">
<nav class="navbar navbar-expand-sm navbar-toggleable-sm navbar-light bg-white border-bottom box-shadow mb-3">
<div class="container-fluid">
<a class="navbar-brand" asp-area="" asp-controller="Home" asp-action="Index">CaseAccountingProviderView</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target=".navbar-collapse" aria-controls="navbarSupportedContent"
aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNavAltMarkup">
<div class="navbar-nav">
<a class="nav-link text-white" asp-area="" asp-controller="Home" asp-action="Cases">Дела</a>
<a class="nav-link text-white" asp-area="" asp-controller="Home" asp-action="Deals">Договора</a>
<a class="nav-link text-white" asp-area="" asp-controller="Home" asp-action="Hearings">Слушания</a>
</div>
<div class="navbar-collapse collapse d-sm-inline-flex justify-content-between">
<ul class="navbar-nav flex-grow-1">
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Index">Home</a>
</li>
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Privacy">Privacy</a>
</li>
</ul>
</div>
</div>
</nav>
@ -31,6 +35,12 @@
@RenderBody()
</main>
</div>
<footer class="border-top footer text-muted">
<div class="container">
&copy; 2023 - CaseAccountingProviderView - <a asp-area="" asp-controller="Home" asp-action="Privacy">Privacy</a>
</div>
</footer>
<script src="~/lib/jquery/dist/jquery.min.js"></script>
<script src="~/lib/bootstrap/dist/js/bootstrap.bundle.min.js"></script>
<script src="~/js/site.js" asp-append-version="true"></script>

View File

@ -5,6 +5,5 @@
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*",
"IPAddress": "http://localhost:5146"
"AllowedHosts": "*"
}

View File

@ -1,69 +0,0 @@
const createBtn = document.getElementById("create-button");
const nameInput = document.getElementById("name-input");
const applicantInput = document.getElementById("applicant-input");
const defendantInput = document.getElementById("defendant-input");
const annotationInput = document.getElementById("annotation-input");
const dateInput = document.getElementById("date-input");
const specializationSelect = document.getElementById("specialization-select");
var specializations = [];
window.addEventListener("load", async () => {
try {
const specializationsResponse = await $.ajax({
url: `/specialization/getall`,
type: "GET",
contentType: "json"
});
specializations = specializationsResponse;
specializations.forEach((specialization) => {
const option = document.createElement("option");
option.value = specialization.id;
option.innerHTML = specialization.name;
specializationSelect.appendChild(option);
specializationSelect.selectedIndex = -1;
});
} catch (error) {
console.error(error);
}
});
createBtn.addEventListener("click", () => {
if (!correctData()) {
return;
}
if (!validate()) {
return;
}
});
const correctData = function () {
return true;
};
const validate = function () {
return true;
};
createBtn.addEventListener("click", () => {
let caseModel = {
"Name": nameInput.value,
"Applicant": applicantInput.value,
"Defendant": defendantInput.value,
"Date": new Date(dateInput.value),
"Annotation": annotationInput.value,
"SpecializationId": parseInt(specializationSelect.value),
};
console.log(caseModel)
$.ajax({
url: "/case/create",
type: "POST",
contentType: "application/json",
data: JSON.stringify(caseModel)
}).done(() => {
window.location.href = "/Home/Cases";
});
});

View File

@ -1,71 +0,0 @@
const updateBtn = document.getElementById("update-button");
const nameInput = document.getElementById("name-input");
const applicantInput = document.getElementById("applicant-input");
const defendantInput = document.getElementById("defendant-input");
const annotationInput = document.getElementById("annotation-input");
const dateInput = document.getElementById("date-input");
const specializationSelect = document.getElementById("specialization-select");
const caseId = document.getElementById("vb-id").dataset.id;
var specializations = [];
window.addEventListener("load", async () => {
try {
const specializationsResponse = await $.ajax({
url: `/specialization/getall`,
type: "GET",
contentType: "json"
});
specializations = specializationsResponse;
specializations.forEach((specialization) => {
const option = document.createElement("option");
option.value = specialization.id;
option.innerHTML = specialization.name;
specializationSelect.appendChild(option);
specializationSelect.selectedIndex = -1;
});
} catch (error) {
console.error(error);
}
});
updateBtn.addEventListener("click", () => {
if (!correctData()) {
return;
}
if (!validate()) {
return;
}
});
const correctData = function () {
return true;
};
const validate = function () {
return true;
};
updateBtn.addEventListener("click", () => {
let caseModel = {
"Id": parseInt(caseId),
"Name": nameInput.value,
"Applicant": applicantInput.value,
"Defendant": defendantInput.value,
"Date": new Date(dateInput.value),
"Annotation": annotationInput.value,
"SpecializationId": parseInt(specializationSelect.value),
};
console.log(caseModel)
$.ajax({
url: "/case/update",
type: "POST",
contentType: "application/json",
data: JSON.stringify(caseModel)
}).done(() => {
window.location.href = "/Home/Cases";
});
});

View File

@ -1,20 +0,0 @@
const removeButtons = document.querySelectorAll(".remove-btn");
console.log(removeButtons)
removeButtons.forEach(function (button) {
button.addEventListener("click", function (event) {
var id = this.dataset.id;
console.log(id)
var result = confirm("Вы уверены, что хотите удалить эту запись?");
if (result) {
$.ajax({
url: "/case/delete",
type: "POST",
data: { Id: id }
}).done(() => {
window.location.reload();
});
}
});
});

View File

@ -1,40 +0,0 @@
const createBtn = document.getElementById("create-button");
const subjectInput = document.getElementById("subject-input");
const responsibilitiesInput = document.getElementById("responsibilities-input");
const dateInput = document.getElementById("date-input");
createBtn.addEventListener("click", () => {
if (!correctData()) {
return;
}
if (!validate()) {
return;
}
});
const correctData = function () {
return true;
};
const validate = function () {
return true;
};
createBtn.addEventListener("click", () => {
let dealModel = {
"Subject": subjectInput.value,
"Responsibilities": responsibilitiesInput.value,
"Date": new Date(dateInput.value)
};
console.log(dealModel)
$.ajax({
url: "/deal/create",
type: "POST",
contentType: "application/json",
data: JSON.stringify(dealModel)
}).done(() => {
window.location.href = "/Home/Deals";
});
});

View File

@ -1,42 +0,0 @@
const updateBtn = document.getElementById("update-button");
const subjectInput = document.getElementById("subject-input");
const responsibilitiesInput = document.getElementById("responsibilities-input");
const dateInput = document.getElementById("date-input");
const dealId = document.getElementById("vb-id").dataset.id;
updateBtn.addEventListener("click", () => {
if (!correctData()) {
return;
}
if (!validate()) {
return;
}
});
const correctData = function () {
return true;
};
const validate = function () {
return true;
};
updateBtn.addEventListener("click", () => {
let dealModel = {
"Id": parseInt(dealId),
"Subject": subjectInput.value,
"Responsibilities": responsibilitiesInput.value,
"Date": new Date(dateInput.value)
};
console.log(dealModel)
$.ajax({
url: "/deal/update",
type: "POST",
contentType: "application/json",
data: JSON.stringify(dealModel)
}).done(() => {
window.location.href = "/Home/Deals";
});
});

View File

@ -1,20 +0,0 @@
const removeButtons = document.querySelectorAll(".remove-btn");
console.log(removeButtons)
removeButtons.forEach(function (button) {
button.addEventListener("click", function (event) {
var id = this.dataset.id;
console.log(id)
var result = confirm("Вы уверены, что хотите удалить эту запись?");
if (result) {
$.ajax({
url: "/deal/delete",
type: "POST",
data: { Id: id }
}).done(() => {
window.location.reload();
});
}
});
});

View File

@ -1,63 +0,0 @@
const createBtn = document.getElementById("create-button");
const informationInput = document.getElementById("information-input");
const dateInput = document.getElementById("date-input");
const caseSelect = document.getElementById("case-select");
var cases = [];
window.addEventListener("load", async () => {
try {
const casesResponse = await $.ajax({
url: `/specialization/getall`,
type: "GET",
contentType: "json"
});
cases = casesResponse;
cases.forEach((element) => {
const option = document.createElement("option");
option.value = element.id;
option.innerHTML = "Дело №" + element.id;
caseSelect.appendChild(option);
caseSelect.selectedIndex = -1;
});
} catch (error) {
console.error(error);
}
});
createBtn.addEventListener("click", () => {
if (!correctData()) {
return;
}
if (!validate()) {
return;
}
});
const correctData = function () {
return true;
};
const validate = function () {
return true;
};
createBtn.addEventListener("click", () => {
let hearingModel = {
"Information": informationInput.value,
"CaseId": parseInt(caseSelect.value),
"Date": new Date(dateInput.value)
};
console.log(dealModel)
$.ajax({
url: "/hearing/create",
type: "POST",
contentType: "application/json",
data: JSON.stringify(hearingModel)
}).done(() => {
window.location.href = "/Home/Hearings";
});
});

View File

@ -1,65 +0,0 @@
const updateBtn = document.getElementById("update-button");
const informationInput = document.getElementById("information-input");
const dateInput = document.getElementById("date-input");
const caseSelect = document.getElementById("case-select");
const hearingId = document.getElementById("vb-id").dataset.id;
var cases = [];
window.addEventListener("load", async () => {
try {
const casesResponse = await $.ajax({
url: `/specialization/getall`,
type: "GET",
contentType: "json"
});
cases = casesResponse;
cases.forEach((element) => {
const option = document.createElement("option");
option.value = element.id;
option.innerHTML = "Дело №" + element.id;
caseSelect.appendChild(option);
caseSelect.selectedIndex = -1;
});
} catch (error) {
console.error(error);
}
});
updateBtn.addEventListener("click", () => {
if (!correctData()) {
return;
}
if (!validate()) {
return;
}
});
const correctData = function () {
return true;
};
const validate = function () {
return true;
};
updateBtn.addEventListener("click", () => {
let hearingModel = {
"Id": parseInt(hearingId),
"Information": informationInput.value,
"CaseId": parseInt(caseSelect.value),
"Date": new Date(dateInput.value)
};
console.log(hearingModel)
$.ajax({
url: "/hearing/update",
type: "POST",
contentType: "application/json",
data: JSON.stringify(hearingModel)
}).done(() => {
window.location.href = "/Home/Hearings";
});
});

View File

@ -1,20 +0,0 @@
const removeButtons = document.querySelectorAll(".remove-btn");
console.log(removeButtons)
removeButtons.forEach(function (button) {
button.addEventListener("click", function (event) {
var id = this.dataset.id;
console.log(id)
var result = confirm("Вы уверены, что хотите удалить эту запись?");
if (result) {
$.ajax({
url: "/hearing/delete",
type: "POST",
data: { Id: id }
}).done(() => {
window.location.reload();
});
}
});
});