last
This commit is contained in:
@@ -33,6 +33,25 @@ namespace Back.Controllers
|
||||
// if (!await _checkPermission.AllowSYSGetCOD(Convert.ToInt32(UserID), user.RolUsers.First().CompanyID)) return Forbid("شما دسترسی به خواندن اطلاعات کالا را نداربد");
|
||||
return Ok(await _servCOD.GetCODs(user.RolUsers.First().CompanyID, itemSerch));
|
||||
}
|
||||
[HttpGet("GetCod/{ID}")]
|
||||
public async Task<ActionResult<RCOD>> GetCod(int ID)
|
||||
{
|
||||
var claim = HttpContext.User.Claims.First(c => c.Type == "UserID");
|
||||
var UserID = claim.Value;
|
||||
var user = await _servUser.GetUserByUserID(Convert.ToInt32(UserID));
|
||||
var cod = await _servCOD.GetCodByCodID(ID, user.RolUsers.First().CompanyID);
|
||||
return Ok(new RCOD
|
||||
{
|
||||
ID = cod.ID,
|
||||
TaxID = cod.ItemTaxID,
|
||||
Title = cod.Title,
|
||||
Unit = cod.CODUnit.Title,
|
||||
UnitID = cod.UnitID,
|
||||
TaxRate = cod.TaxRate
|
||||
|
||||
|
||||
});
|
||||
}
|
||||
[HttpGet("GetAllForidName")]
|
||||
public async Task<ActionResult<List<CODIdName<int>>>> GetAllForidName()
|
||||
{
|
||||
|
@@ -78,7 +78,8 @@ namespace Back.Services
|
||||
public async Task<CODItem?> GetCodByCodID(int CodID, int CompanyID)
|
||||
{
|
||||
return await _CODRepo
|
||||
.Get(w => w.ID == CodID && w.CompanyID == CompanyID && !w.IsDeleted).FirstOrDefaultAsync();
|
||||
.Get(w => w.ID == CodID && w.CompanyID == CompanyID && !w.IsDeleted)
|
||||
.Include(inc=>inc.CODUnit).FirstOrDefaultAsync();
|
||||
}
|
||||
public async Task<bool> ExistCodByCompanyID(int CodID, int CompanyID)
|
||||
{
|
||||
|
@@ -5,6 +5,7 @@ using Back.Data.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.IdentityModel.Tokens;
|
||||
using Shared.DTOs;
|
||||
using System.Data.SqlTypes;
|
||||
using System.IdentityModel.Tokens.Jwt;
|
||||
using System.Reflection;
|
||||
using System.Security.Claims;
|
||||
@@ -20,12 +21,20 @@ namespace Back.Services
|
||||
private readonly IAsyncRepository<User> _RepoUser;
|
||||
private readonly RepositoryBase<Company> _RepoCompany;
|
||||
private readonly IAsyncRepository<PermissionPeriod> _RepoPermissionPeriod;
|
||||
|
||||
private readonly IAsyncRepository<Customer> _RepoCus;
|
||||
private readonly IAsyncRepository<Invoice> _RepoInvoice;
|
||||
private readonly IAsyncRepository<CODItem> _RepoCODItem;
|
||||
public servUser(IConfiguration configuration
|
||||
, servNotification servNotification
|
||||
, IAsyncRepository<User> RepoUser
|
||||
, IAsyncRepository<PermissionPeriod> RepoPermissionPeriod
|
||||
, RepositoryBase<Company> repoCompany)
|
||||
, RepositoryBase<Company> repoCompany, IAsyncRepository<Customer> RepoCus
|
||||
, IAsyncRepository<Invoice> RepoInvoice, IAsyncRepository<CODItem> RepoCODItem)
|
||||
{
|
||||
_RepoCus = RepoCus;
|
||||
_RepoInvoice = RepoInvoice;
|
||||
_RepoCODItem = RepoCODItem;
|
||||
_configuration = configuration;
|
||||
_servNotification = servNotification;
|
||||
_RepoUser = RepoUser;
|
||||
@@ -212,7 +221,7 @@ namespace Back.Services
|
||||
}
|
||||
request.LastLoginDate = _RepoUser.Get(w => w.ID == UserID).Select(s => s.DateLastLogin).FirstOrDefault();
|
||||
if (!string.IsNullOrEmpty(request.LastLoginDate))
|
||||
request.LastLoginDate.ShamciToFormatShamci();
|
||||
request.LastLoginDate = $"{request.LastLoginDate.Substring(8, 2)}:{request.LastLoginDate.Substring(10, 2)} {request.LastLoginDate.Substring(0, 4)}/{request.LastLoginDate.Substring(4, 2)}/{request.LastLoginDate.Substring(6, 2)}";
|
||||
|
||||
|
||||
//if (user.Mobile == user.Username)
|
||||
@@ -238,6 +247,50 @@ namespace Back.Services
|
||||
Path = s.Path,
|
||||
ViewSize = s.ViewSize
|
||||
}).ToList();
|
||||
|
||||
LastActivitySevice lastInvoice = new LastActivitySevice();
|
||||
#region LastActivitySevice
|
||||
//invoice
|
||||
var lastinv = await _RepoInvoice.Get(w => w.CompanyID == user.RolUsers.First().CompanyID && !w.IsDeleted)
|
||||
.Include(inc=>inc.Customer)
|
||||
.Select(s=>new LastActivitySevice
|
||||
{
|
||||
ID = s.ID,
|
||||
Date=s.InvoiceDate.ShamciToFormatShamci(),
|
||||
Name=s.Customer.FullName,
|
||||
PermissionID=3,
|
||||
TypeTitle=s.invoiceType.GetEnumDisplayName()
|
||||
})
|
||||
.OrderByDescending(o => o.ID).FirstOrDefaultAsync();
|
||||
if (lastinv!=null)
|
||||
request.lastActivitiesSevices.Add(lastinv);
|
||||
//cod
|
||||
var lastcod = await _RepoCODItem.Get(w => w.CompanyID == user.RolUsers.First().CompanyID && !w.IsDeleted)
|
||||
.Select(s => new LastActivitySevice
|
||||
{
|
||||
ID = s.ID,
|
||||
Date = "",
|
||||
Name = s.Title,
|
||||
PermissionID = 4,
|
||||
TypeTitle = ""
|
||||
})
|
||||
.OrderByDescending(o => o.ID).FirstOrDefaultAsync();
|
||||
if (lastcod != null)
|
||||
request.lastActivitiesSevices.Add(lastcod);
|
||||
//cus
|
||||
var lastcus = await _RepoCus.Get(w => w.CompanyID == user.RolUsers.First().CompanyID && !w.IsDeleted)
|
||||
.Select(s => new LastActivitySevice
|
||||
{
|
||||
ID = s.ID,
|
||||
Date = "",
|
||||
Name = s.FullName,
|
||||
PermissionID = 8,
|
||||
TypeTitle = ""
|
||||
})
|
||||
.OrderByDescending(o => o.ID).FirstOrDefaultAsync();
|
||||
if (lastcus != null)
|
||||
request.lastActivitiesSevices.Add(lastcus);
|
||||
#endregion
|
||||
return request;
|
||||
}
|
||||
public async Task<User> UpdateUser(User user)
|
||||
|
Reference in New Issue
Block a user