verified field in car, fixed missing public declarations there as well

This commit is contained in:
Nikolai Papin 2024-09-07 12:18:30 +03:00
parent e1f9b65d84
commit 83c9b7fe6e
2 changed files with 53 additions and 4 deletions

View File

@ -9,11 +9,12 @@ public class Car
[Required]
public string Number { get; set; } = null!;
[Required]
Polis Polis { get; set; } = null!;
public Polis Polis { get; set; } = null!;
[Required]
long PolisId { get; set; }
public long PolisId { get; set; }
[Required]
User Resp { get; set; } = null!;
public User Resp { get; set; } = null!;
[Required]
long RespId { get; set; }
public long RespId { get; set; }
public bool Verified { get; set; }
}

View File

@ -0,0 +1,48 @@
using Microsoft.EntityFrameworkCore;
using Renis.Database;
using Renis.Database.Models;
namespace Renis.Repositories;
public class PolisRepository(ApplicationContext db) : IPolisRepository
{
private readonly ApplicationContext _db = db;
public async Task<bool> AddPolis(Polis polis)
{
_db.Polises.Add(polis);
return await Save();
}
public async Task<bool> DeletePolis(Polis polis)
{
_db.Polises.Remove(polis);
return await Save();
}
public async Task<Polis?> GetPolisById(long id)
{
return await _db.Polises.FirstOrDefaultAsync(x => x.Id == id);
}
public async Task<Polis?> GetPolisByNumber(string number)
{
return await _db.Polises.FirstOrDefaultAsync(x => x.Number == number);
}
public IQueryable<Polis> GetPolises()
{
return _db.Polises.AsQueryable();
}
public async Task<bool> Save()
{
return await _db.SaveChangesAsync() > 0;
}
public async Task<bool> UpdatePolis(Polis polis)
{
_db.Polises.Update(polis);
return await Save();
}
}