..
This commit is contained in:
@@ -59,8 +59,8 @@ namespace Back.Controllers
|
||||
// return BadRequest(item);
|
||||
|
||||
//-----GetUserAndCompany
|
||||
var claim = HttpContext.User.Claims.First(c => c.Type == "UserID");
|
||||
var UserID = claim.Value;
|
||||
var claim = "64"/* HttpContext.User.Claims.First(c => c.Type == "UserID")*/;
|
||||
var UserID = claim;
|
||||
var user = await _servUser.GetUserByUserID(Convert.ToInt32(UserID));
|
||||
|
||||
//-----Validaton
|
||||
|
||||
@@ -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; }
|
||||
|
||||
@@ -6,6 +6,7 @@ using Back.Services;
|
||||
using Back.Validations;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.IdentityModel.Tokens;
|
||||
using Microsoft.OpenApi.Models;
|
||||
using System.Text;
|
||||
using TaxPayer.Infrastructure.Persistence;
|
||||
|
||||
@@ -16,7 +17,34 @@ var builder = WebApplication.CreateBuilder(args);
|
||||
builder.Services.AddControllers();
|
||||
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
|
||||
builder.Services.AddEndpointsApiExplorer();
|
||||
builder.Services.AddSwaggerGen();
|
||||
builder.Services.AddSwaggerGen(option =>
|
||||
{
|
||||
option.SwaggerDoc("v1", new OpenApiInfo { Title = "TaxPayer API", Version = "Preview" });
|
||||
option.AddSecurityDefinition("Bearer", new OpenApiSecurityScheme
|
||||
{
|
||||
In = ParameterLocation.Header,
|
||||
Description = "Please enter a valid token",
|
||||
Name = "Authorization",
|
||||
Type = SecuritySchemeType.Http,
|
||||
BearerFormat = "JWT",
|
||||
Scheme = "Bearer"
|
||||
});
|
||||
option.AddSecurityRequirement(new OpenApiSecurityRequirement
|
||||
{
|
||||
{
|
||||
new OpenApiSecurityScheme
|
||||
{
|
||||
Reference = new OpenApiReference
|
||||
{
|
||||
Type=ReferenceType.SecurityScheme,
|
||||
Id="Bearer"
|
||||
}
|
||||
},
|
||||
new string[]{}
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
builder.Services.AddDbContext<SqlDbContext>(options =>
|
||||
{
|
||||
options.UseSqlServer(builder.Configuration.GetConnectionString("Base"));
|
||||
@@ -27,7 +55,7 @@ builder.Services.AddScoped<Back.Services.ServBase>();
|
||||
builder.Services.AddScoped<MobileValidation> ();
|
||||
builder.Services.AddScoped<Service.Main>();
|
||||
builder.Services.AddScoped<servTicket > ();
|
||||
builder.Services.AddScoped < ServValidatinMsg>();
|
||||
builder.Services.AddScoped<ServValidatinMsg>();
|
||||
builder.Services.AddScoped<GetVerificationValidation> ();
|
||||
builder.Services.AddScoped<GetVerificationValidation>();
|
||||
builder.Services.AddScoped<CheckPermission>();
|
||||
|
||||
@@ -17,10 +17,10 @@ namespace Back.Services
|
||||
}
|
||||
private async Task<bool> AllowPermissionInCompany(int CompanyID,int PermissionID,int Allowednumber = 1)
|
||||
{
|
||||
|
||||
PermissionPeriod? permissionPeriod = _repoPermissionPeriod
|
||||
.Get(w => w.CompanyID == CompanyID && w.PermissionID == PermissionID && (!w.IsLocked.HasValue || !w.IsLocked.Value))
|
||||
.FirstOrDefault();
|
||||
PermissionPeriod permissionPeriod =await _repoPermissionPeriod
|
||||
.TrackingGet(w => w.CompanyID == CompanyID && w.PermissionID == PermissionID && (!w.IsLocked.HasValue || !w.IsLocked.Value)
|
||||
)
|
||||
.FirstOrDefaultAsync();
|
||||
|
||||
if (permissionPeriod == null)
|
||||
return false;
|
||||
@@ -51,7 +51,8 @@ namespace Back.Services
|
||||
{
|
||||
|
||||
return await _repoPermissionUser
|
||||
.Get(w => w.RolUser.UserID == UserID && w.RolUser.CompanyID == CompanyID && w.PermissionID==PermissionID)
|
||||
.TrackingGet(w => w.RolUser.UserID == UserID && w.RolUser.CompanyID == CompanyID && w.PermissionID==PermissionID
|
||||
)
|
||||
.AnyAsync();
|
||||
|
||||
|
||||
@@ -59,10 +60,10 @@ namespace Back.Services
|
||||
}
|
||||
public async Task<bool> ExtensionofAccess(int CompanyID, int PermissionID, string value)
|
||||
{
|
||||
PermissionPeriod? permissionPeriod = _repoPermissionPeriod
|
||||
.Get(w => w.CompanyID == CompanyID && w.PermissionID == PermissionID
|
||||
PermissionPeriod permissionPeriod = await _repoPermissionPeriod
|
||||
.TrackingGet(w => w.CompanyID == CompanyID && w.PermissionID == PermissionID
|
||||
&& (!w.IsLocked.HasValue || !w.IsLocked.Value))
|
||||
.FirstOrDefault();
|
||||
.FirstOrDefaultAsync();
|
||||
|
||||
|
||||
//تعداد
|
||||
@@ -76,8 +77,8 @@ namespace Back.Services
|
||||
}
|
||||
try
|
||||
{
|
||||
|
||||
return await _repoPermissionPeriod.UpdateAsync(permissionPeriod);
|
||||
var res= await _repoPermissionPeriod.UpdateAsync(permissionPeriod);
|
||||
return res;
|
||||
//SysLog log = new SysLog()
|
||||
//{
|
||||
// TraceIdentifierID = _httpContextAccessor.HttpContext.TraceIdentifier,
|
||||
|
||||
@@ -107,7 +107,7 @@ namespace Back.Services
|
||||
|
||||
if (item.ID == null || item.ID <= 0)
|
||||
{
|
||||
if (await _checkPermission.ExtensionofAccess(item.CompanyID, 5, "-1"))
|
||||
if (await _checkPermission.ExtensionofAccess(item.CompanyID, 4, "-1"))
|
||||
return await _CODRepo.AddBoolResultAsync(item);
|
||||
|
||||
return false;
|
||||
|
||||
@@ -136,11 +136,11 @@ namespace Back.Services
|
||||
invoice.PreparedtoSendtoTax = false;
|
||||
if (calculate)
|
||||
{
|
||||
if (await _checkPermission.ExtensionofAccess(invoice.CompanyID.Value, 3, "-1"))
|
||||
{
|
||||
//if (await _checkPermission.ExtensionofAccess(invoice.CompanyID.Value, 3, "-1"))
|
||||
// {
|
||||
var item= await _invoiceRepo.AddAsync(invoice);
|
||||
return item.ID;
|
||||
}
|
||||
// }
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user