..
This commit is contained in:
@@ -11,6 +11,7 @@ namespace Back.Data.Contracts
|
||||
public interface IAsyncRepository<T>
|
||||
{
|
||||
IQueryable<T> GetAll();
|
||||
IQueryable<T> TrackingGet(Expression<Func<T, bool>> predicate);
|
||||
IQueryable<T> Get(Expression<Func<T, bool>> predicate);
|
||||
IQueryable<T> Get(Expression<Func<T, bool>> predicate = null,
|
||||
Func<IQueryable<T>, IOrderedQueryable<T>> orderBy = null,
|
||||
|
@@ -30,10 +30,14 @@ namespace Back.Data.Infrastructure.Repository
|
||||
public IQueryable<T> Get(Expression<Func<T, bool>> predicate)
|
||||
{
|
||||
var query = _query.AsQueryable();
|
||||
query = query.AsNoTracking();
|
||||
// query = query.AsNoTracking();
|
||||
return query.Where(predicate).AsQueryable();
|
||||
}
|
||||
public IQueryable<T> TrackingGet(Expression<Func<T, bool>> predicate)
|
||||
{
|
||||
var query = _query.AsQueryable();
|
||||
return query.Where(predicate).AsQueryable();
|
||||
}
|
||||
|
||||
public IQueryable<T> Get(
|
||||
Expression<Func<T, bool>> predicate = null,
|
||||
Func<IQueryable<T>, IOrderedQueryable<T>> orderBy = null,
|
||||
@@ -80,9 +84,18 @@ namespace Back.Data.Infrastructure.Repository
|
||||
|
||||
public async Task<T> AddAsync(T entity)
|
||||
{
|
||||
await _query.AddAsync(entity);
|
||||
await _dbContext.SaveChangesAsync();
|
||||
return entity;
|
||||
try
|
||||
{
|
||||
await _query.AddAsync(entity);
|
||||
await _dbContext.SaveChangesAsync();
|
||||
return entity;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
throw;
|
||||
}
|
||||
|
||||
}
|
||||
public T? Add(T entity)
|
||||
{
|
||||
@@ -109,7 +122,7 @@ namespace Back.Data.Infrastructure.Repository
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
|
||||
_dbContext.Entry(entity).State = EntityState.Modified;
|
||||
var result = await _dbContext.SaveChangesAsync();
|
||||
return result > 0;
|
||||
|
@@ -26,7 +26,7 @@ namespace Back.Data.Models
|
||||
public long? Indati2m { get { return new DateTimeOffset(InvoiceDate.Trim().ToMiladi()).ToUnixTimeMilliseconds(); } }
|
||||
//نوع صورتحساب
|
||||
[MaxLength(1)]
|
||||
public int? inty { get { return pattern.BillType.inty; } }
|
||||
public int? inty { get { return pattern?.BillType.inty; } }
|
||||
//الگوی صورتحساب
|
||||
[MaxLength(2)]
|
||||
public int? inp { get { return pattern?.inp; } }
|
||||
@@ -102,7 +102,7 @@ namespace Back.Data.Models
|
||||
public InvoiceType invoiceType { get; set; }
|
||||
//شماره منحصر به فرد مالیاتی
|
||||
[MaxLength(22)]
|
||||
public string? taxid { get; set; }
|
||||
public string? taxid { get; set; }
|
||||
//شماره منحصر به فرد مالیاتی صورتحساب مرجع
|
||||
[MaxLength(22)]
|
||||
public string? irtaxid { get; set; }
|
||||
@@ -160,13 +160,13 @@ namespace Back.Data.Models
|
||||
public virtual Customer Customer { get; set; }
|
||||
[ForeignKey("LastChangeUserID")]
|
||||
public virtual User user { get; set; }
|
||||
public virtual ICollection<InvoiceItem> invoiceDetails { get; set; }
|
||||
public virtual ICollection<InvoiceItem>? invoiceDetails { get; set; }
|
||||
[ForeignKey("BillReference")]
|
||||
public virtual Invoice? invoice { get; set; }
|
||||
public virtual ICollection<InvoicePayment> payments { get; set; }
|
||||
public virtual ICollection<InvoiceStatusChang> invoiceStatusChangs { get; set; }
|
||||
public virtual ICollection<SentTax> sentTax { get; set; }
|
||||
[ForeignKey("PatternsID")]
|
||||
public virtual ICollection<InvoicePayment>? payments { get; set; }
|
||||
public virtual ICollection<InvoiceStatusChang>? invoiceStatusChangs { get; set; }
|
||||
public virtual ICollection<SentTax>? sentTax { get; set; }
|
||||
[ForeignKey("PatternID")]
|
||||
public virtual Pattern? pattern { get; set; }
|
||||
[ForeignKey("CompanyID")]
|
||||
public virtual Company? company { get; set; }
|
||||
|
Reference in New Issue
Block a user