...
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Melipayamak.RestClient" Version="1.0.0" />
|
||||
<PackageReference Include="Microsoft.Data.SqlClient" Version="5.2.0" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0" />
|
||||
<PackageReference Include="FluentValidation" Version="11.9.0" />
|
||||
@@ -34,7 +35,7 @@
|
||||
|
||||
<ItemGroup>
|
||||
<Reference Include="Service">
|
||||
<HintPath>..\..\Dlls\Service.dll</HintPath>
|
||||
<HintPath>..\..\..\LocalGit\TaxPayerTools\Service\bin\Debug\Service.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
|
||||
|
@@ -1,5 +1,9 @@
|
||||
using Back.Services;
|
||||
using Back.Common;
|
||||
using Back.Data.Models;
|
||||
using Back.Services;
|
||||
using Back.Validations;
|
||||
using FluentValidation;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Shared.DTOs;
|
||||
@@ -12,10 +16,25 @@ namespace Back.Controllers
|
||||
{
|
||||
private readonly ServBase _sBase;
|
||||
private readonly MobileValidation _mobilevalidation;
|
||||
public BaseController(ServBase sBase, MobileValidation mobilevalidation)
|
||||
private readonly servCompany _servCompany;
|
||||
private readonly servUser _servUser;
|
||||
private readonly servPermission _servPermission;
|
||||
private readonly ServValidatinMsg _servValidatinMsg;
|
||||
private readonly servSendMsg _servSendMsg;
|
||||
private readonly CompanyRegistrationValidation _companyRegistrationValidation;
|
||||
public BaseController(ServBase sBase, MobileValidation mobilevalidation
|
||||
, servCompany servCompany, servUser servUser
|
||||
, servPermission servPermission, ServValidatinMsg servValidatinMsg
|
||||
, servSendMsg servSendMsg, CompanyRegistrationValidation companyRegistrationValidation)
|
||||
{
|
||||
_sBase = sBase;
|
||||
_mobilevalidation = mobilevalidation;
|
||||
_servCompany = servCompany;
|
||||
_servUser = servUser;
|
||||
_servPermission = servPermission;
|
||||
_servValidatinMsg = servValidatinMsg;
|
||||
_servSendMsg = servSendMsg;
|
||||
_companyRegistrationValidation = companyRegistrationValidation;
|
||||
}
|
||||
[HttpGet("Pricing")]
|
||||
public async Task<ActionResult<List<BasePriceDto>>> Pricing()
|
||||
@@ -24,14 +43,14 @@ namespace Back.Controllers
|
||||
public async Task<ActionResult<DateTime>> DateTimeServer()
|
||||
=> Ok(DateTime.Now);
|
||||
[HttpGet("LastBlog")]
|
||||
public async Task<ActionResult<PagingDto<BlogDto>>> LastBlog(int PageIndex,int PageSize)
|
||||
=> Ok(await _sBase.GetBlog(PageIndex,PageSize));
|
||||
public async Task<ActionResult<PagingDto<BlogDto>>> LastBlog(int PageIndex, int PageSize)
|
||||
=> Ok(await _sBase.GetBlog(PageIndex, PageSize));
|
||||
[HttpGet("GetBlogByID/{ID}")]
|
||||
public async Task<ActionResult<BlogDtoFull?>> GetBlogByID(int ID)
|
||||
{
|
||||
var result = await _sBase.GetBlogByID(ID);
|
||||
if (result == null)
|
||||
return NotFound();
|
||||
return NotFound();
|
||||
return Ok(result);
|
||||
}
|
||||
[HttpGet("LastQuestion")]
|
||||
@@ -42,18 +61,112 @@ namespace Back.Controllers
|
||||
{
|
||||
var resultValidationmodel = await _mobilevalidation.ValidateAsync(model.Mobile);
|
||||
if (!resultValidationmodel.IsValid)
|
||||
return BadRequest(resultValidationmodel.Errors.Select(s=>s.ErrorMessage ).ToList());
|
||||
return BadRequest(resultValidationmodel.Errors.Select(s => s.ErrorMessage).ToList());
|
||||
return Ok(await _sBase.CreateCsrAndPrivateKey(model));
|
||||
}
|
||||
[HttpPost("ReadPublicKeyFromCER")]
|
||||
public async Task<ActionResult<PublicKeyDTO>> ReadPublicKeyFromCER(string modelfromBase64)
|
||||
{
|
||||
var result = await _sBase.ReadPublicKeyFromCER(modelfromBase64);
|
||||
if (result.type== "error")
|
||||
if (result.type == "error")
|
||||
return BadRequest();
|
||||
|
||||
return Ok(result);
|
||||
|
||||
return Ok(result);
|
||||
}
|
||||
|
||||
[HttpPost("CompanyRegistration")]
|
||||
[AllowAnonymous]
|
||||
public async Task<ActionResult<string>> CompanyRegistration([FromBody] CompanyRegistrationDTO item)
|
||||
{
|
||||
|
||||
var resultValidationmodel = await _companyRegistrationValidation.ValidateAsync(item);
|
||||
if (!resultValidationmodel.IsValid)
|
||||
return BadRequest(resultValidationmodel.Errors.Select(s => s.ErrorMessage).ToList());
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
var user = new User()
|
||||
{
|
||||
Fullname = item.FullnameUser,
|
||||
Mobile = item.Mobile,
|
||||
Username = item.Username,
|
||||
Password = item.Mobile.encrypted(),
|
||||
IsActive = false
|
||||
|
||||
};
|
||||
user = await _servUser.AddUser(user);
|
||||
|
||||
var company =await _servCompany.GetCompanyOrgByMobileAndCompanynotActive(item.Mobile);
|
||||
if (company==null)
|
||||
{
|
||||
company = new Company()
|
||||
{
|
||||
Name = item.CompanyName,
|
||||
Mobile = item.Mobile,
|
||||
RegisterDate = DateTime.Now.ConvertMiladiToShamsi(),
|
||||
IsActive = false
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
company.Name = item.CompanyName;
|
||||
company.RegisterDate = DateTime.Now.ConvertMiladiToShamsi();
|
||||
company.IsActive = false;
|
||||
}
|
||||
|
||||
company = await _servCompany.AddORUpdateCompany(company);
|
||||
|
||||
var allper = await _servPermission.GetPermissions();
|
||||
|
||||
var roluser = new RolUser()
|
||||
{
|
||||
CompanyID = company.ID,
|
||||
UserID = user.ID,
|
||||
IsAdmin = true
|
||||
};
|
||||
roluser = await _servPermission.AddRolUser(roluser);
|
||||
|
||||
await _servPermission.AddRangePermissionPeriodByCompany(new List<PermissionPeriod>()
|
||||
{
|
||||
new PermissionPeriod(){CompanyID=company.ID,PermissionID=2,CalculationTypeID=2,RemainingAmount=0,TotalAmount=0},
|
||||
new PermissionPeriod(){CompanyID=company.ID,PermissionID=3,CalculationTypeID=1,RemainingAmount=5,TotalAmount=5},
|
||||
new PermissionPeriod(){CompanyID=company.ID,PermissionID=4,CalculationTypeID=1,RemainingAmount=5,TotalAmount=5},
|
||||
new PermissionPeriod(){CompanyID=company.ID,PermissionID=5,CalculationTypeID=1,RemainingAmount=5,TotalAmount=5},
|
||||
new PermissionPeriod(){CompanyID=company.ID,PermissionID=16,CalculationTypeID=1,RemainingAmount=5,TotalAmount=5},
|
||||
new PermissionPeriod(){CompanyID=company.ID,PermissionID=6,CalculationTypeID=2,RemainingAmount=0,TotalAmount=0}
|
||||
|
||||
});
|
||||
|
||||
await _servPermission.AddPermissionUser(roluser.ID, allper.Select(s => s.ID).ToArray());
|
||||
|
||||
var ID = await _servValidatinMsg.GenerateCode(new VerificationCode
|
||||
{
|
||||
prm = company.ID.ToString(),
|
||||
val = user.ID.ToString(),
|
||||
Type = "CompanyRegistration"
|
||||
});
|
||||
|
||||
_servSendMsg.Authentication(company.Mobile, ID.ToString());
|
||||
return Ok(ID);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
//SysLog log = new SysLog()
|
||||
//{
|
||||
// TraceIdentifierID = HttpContext.TraceIdentifier,
|
||||
// Datetime = DateTime.Now.ConvertMiladiToShamsi(),
|
||||
// Method = HttpContext.Request.Method,
|
||||
// Value = ex.Message,
|
||||
// Route = HttpContext.Request.Path,
|
||||
// Type = "catch"
|
||||
//};
|
||||
//_contextMongodb.InsertItem(log);
|
||||
return BadRequest("خطای سیستمی رخ داده");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@@ -7,6 +7,7 @@ using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Shared.DTOs;
|
||||
using System.Security.Cryptography;
|
||||
using static Microsoft.EntityFrameworkCore.DbLoggerCategory.Database;
|
||||
|
||||
namespace Back.Controllers
|
||||
{
|
||||
@@ -18,11 +19,14 @@ namespace Back.Controllers
|
||||
private readonly MobileValidation _mobilevalidation;
|
||||
private readonly servTicket _servTicket;
|
||||
private readonly ServValidatinMsg _servValidatinMsg;
|
||||
public TicketController(MobileValidation mobilevalidation, servTicket servTicket, ServValidatinMsg servValidatinMsg)
|
||||
private readonly servSendMsg _servSendMsg;
|
||||
public TicketController(MobileValidation mobilevalidation, servTicket servTicket
|
||||
, ServValidatinMsg servValidatinMsg, servSendMsg servSendMsg)
|
||||
{
|
||||
_mobilevalidation = mobilevalidation;
|
||||
_servTicket = servTicket;
|
||||
_servValidatinMsg = servValidatinMsg;
|
||||
_servSendMsg = servSendMsg;
|
||||
}
|
||||
|
||||
[HttpPost("NewTicketNoAuthentication")]
|
||||
@@ -41,9 +45,9 @@ namespace Back.Controllers
|
||||
{
|
||||
prm = Ticket.ID.ToString(),
|
||||
val = item.Mobile,
|
||||
Type = "NewTicketNoAuthentication"
|
||||
Type = "NewTicketNoAuthentication"
|
||||
});
|
||||
|
||||
_servSendMsg.Authentication(item.Mobile, ID.ToString());
|
||||
return Ticket == null ? BadRequest() : Ok(ID);
|
||||
}
|
||||
}
|
||||
|
38
Back/Controllers/UserController.cs
Normal file
38
Back/Controllers/UserController.cs
Normal file
@@ -0,0 +1,38 @@
|
||||
using Back.Services;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Shared.DTOs;
|
||||
|
||||
namespace Back.Controllers
|
||||
{
|
||||
[Route("api/[controller]")]
|
||||
[ApiController]
|
||||
public class UserController : ControllerBase
|
||||
{
|
||||
private readonly servUser _servUser;
|
||||
public UserController(servUser servUser)
|
||||
{
|
||||
|
||||
_servUser = servUser;
|
||||
|
||||
}
|
||||
[HttpPost("authenticate")]
|
||||
[AllowAnonymous]
|
||||
public async Task<ActionResult<UserAuthenticationDTO>> Login(Authentication model)
|
||||
{
|
||||
if (!ModelState.IsValid) return BadRequest(model);
|
||||
var result = await _servUser.UserAuthentication(model.Username, model.Password);
|
||||
if (result != null) return Ok(result);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
else return NotFound("کاربری با این مشخصات یافت نشد");
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@@ -5,6 +5,7 @@ using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Shared.DTOs;
|
||||
using static Microsoft.EntityFrameworkCore.DbLoggerCategory.Database;
|
||||
|
||||
namespace Back.Controllers
|
||||
{
|
||||
@@ -14,11 +15,14 @@ namespace Back.Controllers
|
||||
{
|
||||
private readonly ServValidatinMsg _servValidatinMsg;
|
||||
private readonly GetVerificationValidation _getVerificationValidation;
|
||||
public VerificationController(ServValidatinMsg servValidatinMsg, GetVerificationValidation getVerificationValidation)
|
||||
private readonly servSendMsg _servSendMsg;
|
||||
private readonly servCompany _servCompany;
|
||||
public VerificationController(ServValidatinMsg servValidatinMsg, GetVerificationValidation getVerificationValidation
|
||||
, servCompany servCompany)
|
||||
{
|
||||
_servValidatinMsg = servValidatinMsg;
|
||||
_getVerificationValidation = getVerificationValidation;
|
||||
|
||||
_servCompany = servCompany;
|
||||
}
|
||||
[HttpGet("GetVerification/{ID}")]
|
||||
[AllowAnonymous]
|
||||
@@ -44,6 +48,22 @@ namespace Back.Controllers
|
||||
if (!resultValidationmodel.IsValid)
|
||||
return BadRequest(resultValidationmodel.Errors.Select(s => s.ErrorMessage).ToList());
|
||||
// _getVerificationValidation.verificationCode
|
||||
|
||||
switch (_getVerificationValidation.verificationCode.Type)
|
||||
{
|
||||
case "NewTicketNoAuthentication":
|
||||
_servSendMsg.Authentication(_getVerificationValidation.verificationCode.val, ID.ToString());
|
||||
break;
|
||||
|
||||
case "CompanyRegistration":
|
||||
var company=await _servCompany.GetCompanyOrg(Convert.ToInt32(_getVerificationValidation.verificationCode.prm),false);
|
||||
_servSendMsg.Authentication(company.Mobile, ID.ToString());
|
||||
break;
|
||||
|
||||
default:
|
||||
return BadRequest("این نوع احراز تعریف نشده");
|
||||
}
|
||||
|
||||
return NoContent();
|
||||
}
|
||||
[HttpPost("Submit")]
|
||||
@@ -64,12 +84,21 @@ namespace Back.Controllers
|
||||
case "NewTicketNoAuthentication":
|
||||
Sucstatus = await _servValidatinMsg.SubmittedTicket(VerificationCode);
|
||||
break;
|
||||
|
||||
case "CompanyRegistration":
|
||||
//string UserID = VerificationCode.val;
|
||||
Sucstatus = await _servValidatinMsg.SubmittedCompanyRegistration(VerificationCode);
|
||||
// return Ok(await _servUser.UserAuthentication(UserID));
|
||||
//else return BadRequest();
|
||||
break;
|
||||
|
||||
default:
|
||||
return BadRequest("این نوع احراز تعریف نشده");
|
||||
}
|
||||
|
||||
if (Sucstatus)
|
||||
await _servValidatinMsg.Delete(VerificationCode);
|
||||
|
||||
|
||||
return Ok(Sucstatus);
|
||||
}
|
||||
else return BadRequest("اطلاعات شما منطبق با سامانه نیست");
|
||||
|
@@ -28,6 +28,8 @@ namespace Back.Data.Contracts
|
||||
bool AddBoolResult(T entity);
|
||||
Task<bool> UpdateAsync(T entity);
|
||||
bool Update(T entity);
|
||||
Task<T?> UpdateByObjAsync(T entity);
|
||||
T? UpdateByObj(T entity);
|
||||
Task<bool> UpdateRangeAsync(ICollection<T> entites);
|
||||
bool UpdateRange(ICollection<T> entites);
|
||||
bool Delete(T entity);
|
||||
|
@@ -134,6 +134,36 @@ namespace Back.Data.Infrastructure.Repository
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
public async Task<T?> UpdateByObjAsync(T entity)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
_dbContext.Entry(entity).State = EntityState.Modified;
|
||||
await _dbContext.SaveChangesAsync();
|
||||
return entity;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return null;
|
||||
throw;
|
||||
}
|
||||
|
||||
}
|
||||
public T? UpdateByObj(T entity)
|
||||
{
|
||||
try
|
||||
{
|
||||
_dbContext.Update(entity);
|
||||
var result = _dbContext.SaveChanges();
|
||||
return entity;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
public async Task<bool> DeleteAsync(T entity)
|
||||
{
|
||||
|
12
Back/FixedValues.cs
Normal file
12
Back/FixedValues.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
namespace Back
|
||||
{
|
||||
public static class Fixedvalues
|
||||
{
|
||||
//public static string ConnectionString = "Data Source=195.88.208.142;Initial Catalog=TaxPayer020713;User ID=sa;Password=M439610m@;TrustServerCertificate=True";
|
||||
public static string SecretForKey = "thisisthesecretforgeneratingakey(mustbeatleast32bitlong)mmrbnjd";
|
||||
public static string Issuer = "http://mmrbnjd.com";
|
||||
public static string Audience = "TaxPayer";
|
||||
//public static string MongoServer = "mongodb://localhost:27017";
|
||||
//public static string Mongodb = "TaxPayerLog";
|
||||
}
|
||||
}
|
@@ -25,7 +25,14 @@ builder.Services.AddScoped<servTicket > ();
|
||||
builder.Services.AddScoped < ServValidatinMsg>();
|
||||
builder.Services.AddScoped<GetVerificationValidation> ();
|
||||
builder.Services.AddScoped<GetVerificationValidation>();
|
||||
|
||||
builder.Services.AddScoped<CheckPermission>();
|
||||
builder.Services.AddScoped<servCompany>();
|
||||
builder.Services.AddScoped<servNotification>();
|
||||
builder.Services.AddScoped<servPermission>();
|
||||
builder.Services.AddScoped<servSendMsg>();
|
||||
builder.Services.AddScoped<servUser>();
|
||||
builder.Services.AddScoped<CompanyRegistrationValidation>();
|
||||
builder.Services.AddScoped(c => new mpNuget.RestClient("09119660045", "C54S2"));
|
||||
|
||||
string origins = "OriginTaxPayer";
|
||||
builder.Services.AddCors(options =>
|
||||
|
239
Back/Services/CheckPermission.cs
Normal file
239
Back/Services/CheckPermission.cs
Normal file
@@ -0,0 +1,239 @@
|
||||
using Back.Common;
|
||||
using Back.Data.Contracts;
|
||||
using Back.Data.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Back.Services
|
||||
{
|
||||
public class CheckPermission
|
||||
{
|
||||
private readonly IAsyncRepository<PermissionPeriod> _repoPermissionPeriod;
|
||||
private readonly IAsyncRepository<PermissionUser> _repoPermissionUser;
|
||||
public CheckPermission(IAsyncRepository<PermissionPeriod> repoPermissionPeriod
|
||||
,IAsyncRepository<PermissionUser> repoPermissionUser)
|
||||
{
|
||||
_repoPermissionPeriod = repoPermissionPeriod;
|
||||
_repoPermissionUser = repoPermissionUser;
|
||||
}
|
||||
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();
|
||||
|
||||
if (permissionPeriod == null)
|
||||
return false;
|
||||
|
||||
//تعداد
|
||||
if (permissionPeriod.CalculationTypeID == 1)
|
||||
{
|
||||
if (permissionPeriod.RemainingAmount < Allowednumber)
|
||||
return false;
|
||||
|
||||
//permissionPeriod.RemainingAmount -= 1;
|
||||
|
||||
}
|
||||
//تا تاریخ
|
||||
else if (permissionPeriod.CalculationTypeID == 3)
|
||||
{
|
||||
|
||||
string date = $"{permissionPeriod.RemainingAmount.ToString().Substring(0, 4)}/{permissionPeriod.RemainingAmount.ToString().Substring(4, 2)}/{permissionPeriod.RemainingAmount.ToString().Substring(6, 2)}";
|
||||
DateTime dateTime = date.ToMiladi();
|
||||
if (DateTime.Now > dateTime)
|
||||
return false;
|
||||
|
||||
}
|
||||
return await _repoPermissionPeriod.UpdateAsync(permissionPeriod);
|
||||
|
||||
}
|
||||
public async Task<bool> AllowPermission(int UserID,int CompanyID, int PermissionID)
|
||||
{
|
||||
|
||||
return await _repoPermissionUser
|
||||
.Get(w => w.RolUser.UserID == UserID && w.RolUser.CompanyID == CompanyID && w.PermissionID==PermissionID)
|
||||
.AnyAsync();
|
||||
|
||||
|
||||
|
||||
}
|
||||
public async Task<bool> ExtensionofAccess(int CompanyID, int PermissionID, string value)
|
||||
{
|
||||
PermissionPeriod? permissionPeriod = _repoPermissionPeriod
|
||||
.Get(w => w.CompanyID == CompanyID && w.PermissionID == PermissionID
|
||||
&& (!w.IsLocked.HasValue || !w.IsLocked.Value))
|
||||
.FirstOrDefault();
|
||||
|
||||
|
||||
//تعداد
|
||||
if (permissionPeriod.CalculationTypeID == 1)
|
||||
{
|
||||
if (permissionPeriod.RemainingAmount < 0)
|
||||
permissionPeriod.RemainingAmount = Convert.ToInt32(value);
|
||||
|
||||
permissionPeriod.RemainingAmount += Convert.ToInt32(value);
|
||||
|
||||
}
|
||||
try
|
||||
{
|
||||
|
||||
return await _repoPermissionPeriod.UpdateAsync(permissionPeriod);
|
||||
//SysLog log = new SysLog()
|
||||
//{
|
||||
// TraceIdentifierID = _httpContextAccessor.HttpContext.TraceIdentifier,
|
||||
// Datetime = DateTime.Now.ConvertMiladiToShamsi(),
|
||||
// Method = $"{_httpContextAccessor.HttpContext.Request.Method}/{this.GetType().FullName}/ExtensionofAccess",
|
||||
// Value = $"{permissionPeriod.RemainingAmount - Convert.ToInt32(value)}+({value})={permissionPeriod.RemainingAmount}",
|
||||
// Route = _httpContextAccessor.HttpContext.Request.Path,
|
||||
// Type = "User"
|
||||
//};
|
||||
//_contextMongodb.InsertItem(log);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
//SysLog log = new SysLog()
|
||||
//{
|
||||
// TraceIdentifierID = _httpContextAccessor.HttpContext.TraceIdentifier,
|
||||
// Datetime = DateTime.Now.ConvertMiladiToShamsi(),
|
||||
// Method = $"{_httpContextAccessor.HttpContext.Request.Method}/{this.GetType().FullName}/ExtensionofAccess",
|
||||
// Value = ex.Message,
|
||||
// Route = _httpContextAccessor.HttpContext.Request.Path,
|
||||
// Type = "catch"
|
||||
//};
|
||||
//_contextMongodb.InsertItem(log);
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//--------Customer---------
|
||||
#region Customer
|
||||
public async Task<bool> AllowAddCustomerInCompany(int CompanyID, int Allowednumber = 1)
|
||||
{
|
||||
//مشتری
|
||||
int PermissionID = 5;
|
||||
return await AllowPermissionInCompany(CompanyID, PermissionID,Allowednumber);
|
||||
|
||||
}
|
||||
public async Task<bool> AllowSYSGetCustomer(int UserID, int CompanyID)
|
||||
{
|
||||
//مشتری
|
||||
int PermissionID = 5;
|
||||
return await AllowPermission(UserID, CompanyID, PermissionID);
|
||||
|
||||
}
|
||||
public async Task<bool> AllowSYSAddCustomer(int UserID, int CompanyID)
|
||||
{
|
||||
//مشتری
|
||||
int PermissionID = 7;
|
||||
return await AllowPermission(UserID,CompanyID, PermissionID);
|
||||
|
||||
}
|
||||
public async Task<bool> AllowSYSDeleteCustomer(int UserID, int CompanyID)
|
||||
{
|
||||
//مشتری
|
||||
int PermissionID = 9;
|
||||
return await AllowPermission(UserID, CompanyID, PermissionID);
|
||||
|
||||
}
|
||||
public async Task<bool> AllowSYSUpdateCustomer(int UserID, int CompanyID)
|
||||
{
|
||||
//مشتری
|
||||
int PermissionID = 8;
|
||||
return await AllowPermission(UserID, CompanyID, PermissionID);
|
||||
|
||||
}
|
||||
#endregion
|
||||
//-----------COD-----------
|
||||
#region COD
|
||||
public async Task<bool> AllowAddCODInCompany(int CompanyID,int Allowednumber=1)
|
||||
{
|
||||
//کالا
|
||||
int PermissionID = 4;
|
||||
return await AllowPermissionInCompany(CompanyID, PermissionID,Allowednumber);
|
||||
|
||||
}
|
||||
public async Task<bool> AllowSYSGetCOD(int UserID, int CompanyID)
|
||||
{
|
||||
//کالا
|
||||
int PermissionID = 4;
|
||||
return await AllowPermission(UserID, CompanyID, PermissionID);
|
||||
|
||||
}
|
||||
public async Task<bool> AllowSYSAddCOD(int UserID, int CompanyID)
|
||||
{
|
||||
//کالا
|
||||
int PermissionID = 10;
|
||||
return await AllowPermission(UserID, CompanyID, PermissionID);
|
||||
|
||||
}
|
||||
public async Task<bool> AllowSYSDeleteCOD(int UserID, int CompanyID)
|
||||
{
|
||||
//کالا
|
||||
int PermissionID = 12;
|
||||
return await AllowPermission(UserID, CompanyID, PermissionID);
|
||||
|
||||
}
|
||||
public async Task<bool> AllowSYSUpdateCOD(int UserID, int CompanyID)
|
||||
{
|
||||
//کالا
|
||||
int PermissionID = 11;
|
||||
return await AllowPermission(UserID, CompanyID, PermissionID);
|
||||
|
||||
}
|
||||
#endregion
|
||||
//--------Invoice---------
|
||||
#region Invoice
|
||||
public async Task<bool> AllowAddInvoiceInCompany(int CompanyID, int Allowednumber = 1)
|
||||
{
|
||||
int PermissionID = 3;
|
||||
return await AllowPermissionInCompany(CompanyID, PermissionID, Allowednumber);
|
||||
|
||||
}
|
||||
public async Task<bool> AllowSYSGetInvoice(int UserID, int CompanyID)
|
||||
{
|
||||
int PermissionID = 3;
|
||||
return await AllowPermission(UserID, CompanyID, PermissionID);
|
||||
|
||||
}
|
||||
public async Task<bool> AllowSYSAddInvoice(int UserID, int CompanyID)
|
||||
{
|
||||
int PermissionID = 13;
|
||||
return await AllowPermission(UserID, CompanyID, PermissionID);
|
||||
|
||||
}
|
||||
public async Task<bool> AllowSYSDeleteInvoice(int UserID, int CompanyID)
|
||||
{
|
||||
int PermissionID = 15;
|
||||
return await AllowPermission(UserID, CompanyID, PermissionID);
|
||||
|
||||
}
|
||||
public async Task<bool> AllowSYSUpdateInvoice(int UserID, int CompanyID)
|
||||
{
|
||||
int PermissionID = 14;
|
||||
return await AllowPermission(UserID, CompanyID, PermissionID);
|
||||
|
||||
}
|
||||
#endregion
|
||||
#region TaxPayer
|
||||
public async Task<bool> AllowSendTaxPayerInCompany(int CompanyID)
|
||||
{
|
||||
int PermissionID = 16;
|
||||
return await AllowPermissionInCompany(CompanyID, PermissionID);
|
||||
|
||||
}
|
||||
public async Task<bool> AllowSYSGetTaxPayer(int UserID, int CompanyID)
|
||||
{
|
||||
int PermissionID = 16;
|
||||
return await AllowPermission(UserID, CompanyID, PermissionID);
|
||||
|
||||
}
|
||||
public async Task<bool> AllowSYSSendTaxPayer(int UserID, int CompanyID)
|
||||
{
|
||||
int PermissionID = 16;
|
||||
return await AllowPermission(UserID, CompanyID, PermissionID);
|
||||
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
@@ -9,10 +9,18 @@ namespace Back.Services
|
||||
{
|
||||
private readonly IAsyncRepository<VerificationCode> _verificationCodeRepo;
|
||||
private readonly IAsyncRepository<Ticket> _ticket;
|
||||
public ServValidatinMsg(IAsyncRepository<VerificationCode> verificationCodeRepo, IAsyncRepository<Ticket> ticket)
|
||||
private readonly IAsyncRepository<User> _UserRepo;
|
||||
private readonly IAsyncRepository<Company> _CompanyRepo;
|
||||
private readonly servSendMsg _servSendMsg;
|
||||
public ServValidatinMsg(IAsyncRepository<VerificationCode> verificationCodeRepo
|
||||
, IAsyncRepository<Ticket> ticket, IAsyncRepository<User> UserRepo
|
||||
, IAsyncRepository<Company> CompanyRepo, servSendMsg servSendMsg)
|
||||
{
|
||||
_verificationCodeRepo = verificationCodeRepo;
|
||||
_ticket = ticket;
|
||||
_UserRepo = UserRepo;
|
||||
_CompanyRepo = CompanyRepo;
|
||||
_servSendMsg = servSendMsg;
|
||||
}
|
||||
public async Task<VerificationCode> GetCodeByPrm(string Prm)
|
||||
{
|
||||
@@ -37,6 +45,26 @@ namespace Back.Services
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public async Task<bool> SubmittedCompanyRegistration(VerificationCode code)
|
||||
{
|
||||
var user = await _UserRepo.Get(w => w.ID == Convert.ToInt32(code.val) && !w.IsActive).FirstOrDefaultAsync();
|
||||
var company = await _CompanyRepo.Get(w => w.ID == Convert.ToInt32(code.prm) && !w.IsActive).FirstOrDefaultAsync();
|
||||
if (user != null && company != null)
|
||||
{
|
||||
user.IsActive = true;
|
||||
if (await _UserRepo.UpdateAsync(user) != null)
|
||||
{
|
||||
company.IsActive = true;
|
||||
if (await _CompanyRepo.UpdateAsync(company))
|
||||
{
|
||||
_servSendMsg.SuccessfulRegistration(user.Mobile, $"{user.Mobile};{user.Mobile}");
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public async Task<int> GenerateCode(VerificationCode code)
|
||||
{
|
||||
code.Code = Random.Shared.Next(1000, 9000);
|
||||
|
112
Back/Services/servCompany.cs
Normal file
112
Back/Services/servCompany.cs
Normal file
@@ -0,0 +1,112 @@
|
||||
using Back.Common;
|
||||
using Back.Data.Contracts;
|
||||
using Back.Data.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Shared.DTOs;
|
||||
|
||||
|
||||
namespace Back.Services
|
||||
{
|
||||
public class servCompany
|
||||
{
|
||||
private readonly IAsyncRepository<RolUser> _repoRolUser;
|
||||
private readonly IAsyncRepository<Company> _repoCompany;
|
||||
|
||||
//private readonly servSendMsg _servSendMsg;
|
||||
public servCompany(IAsyncRepository<RolUser> repoRolUser, IAsyncRepository<Company> repoCompany)
|
||||
{
|
||||
_repoCompany = repoCompany;
|
||||
_repoRolUser = repoRolUser;
|
||||
}
|
||||
public async Task<bool> ExsistCompanyByComoanyIDandUserID(int ComoanyID, int UserID,bool InAdmin=false)
|
||||
{
|
||||
var res= _repoRolUser.Get(w => w.CompanyID == ComoanyID && w.UserID == UserID && w.Company.IsActive);
|
||||
if (InAdmin)
|
||||
res = res.Where( w=> w.IsAdmin);
|
||||
|
||||
return await res.AnyAsync();
|
||||
}
|
||||
public async Task<CompanyDTO?> GetCompany(int ComoanyID)
|
||||
{
|
||||
return await _repoCompany.Get(w => w.ID == ComoanyID && w.IsActive)
|
||||
.Select(s=>new CompanyDTO()
|
||||
{
|
||||
BranchID = s.BranchID,
|
||||
EconomicCode = s.EconomicCode,
|
||||
ID = s.ID,
|
||||
Email = s.Email,
|
||||
Logo= s.Logo==null ?null: System.Text.Encoding.UTF8.GetString(s.Logo) ,
|
||||
Mobile = s.Mobile,
|
||||
Name = s.Name,
|
||||
Phone = s.Phone,
|
||||
PrivateKey= s.PrivateKey,
|
||||
UniqeMemory = s.UniqeMemory
|
||||
}).FirstOrDefaultAsync();
|
||||
}
|
||||
public async Task<Company?> GetCompanyOrg(int ComoanyID,bool IsActive=true)
|
||||
{
|
||||
var inv = _repoCompany.Get(w => w.ID == ComoanyID);
|
||||
if (IsActive)
|
||||
inv= inv.Where(w=>w.IsActive);
|
||||
|
||||
return await inv.FirstOrDefaultAsync();
|
||||
}
|
||||
public async Task<Company?> GetCompanyOrgByMobileAndCompanynotActive(string Mobile)
|
||||
{
|
||||
var inv = _repoCompany.Get(w => w.Mobile == Mobile && !w.IsActive);
|
||||
return await inv.FirstOrDefaultAsync();
|
||||
}
|
||||
public async Task<Company> AddORUpdateCompany(Company item)
|
||||
{
|
||||
|
||||
try
|
||||
{
|
||||
//SysLog log = new SysLog()
|
||||
//{
|
||||
// TraceIdentifierID = _httpContextAccessor.HttpContext.TraceIdentifier,
|
||||
// Datetime = DateTime.Now.ConvertMiladiToShamsi(),
|
||||
// Method = $"{_httpContextAccessor.HttpContext.Request.Method}/{this.GetType().FullName}/AddORUpdateCompany",
|
||||
// Value = "*" + JsonConvert.SerializeObject(item),
|
||||
// Route = _httpContextAccessor.HttpContext.Request.Path,
|
||||
// Type = "User"
|
||||
//};
|
||||
//_contextMongodb.InsertItem(log);
|
||||
|
||||
if (item.ID == null || item.ID ==0)
|
||||
{
|
||||
return await _repoCompany.AddAsync(item);
|
||||
}
|
||||
else
|
||||
{
|
||||
return await _repoCompany.UpdateByObjAsync(item);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
//SysLog log = new SysLog()
|
||||
//{
|
||||
// TraceIdentifierID = _httpContextAccessor.HttpContext.TraceIdentifier,
|
||||
// Datetime = DateTime.Now.ConvertMiladiToShamsi(),
|
||||
// Method = $"{_httpContextAccessor.HttpContext.Request.Method}/{this.GetType().FullName}/AddORUpdateCompany",
|
||||
// Value = ex.Message,
|
||||
// Route = _httpContextAccessor.HttpContext.Request.Path,
|
||||
// Type = "catch"
|
||||
//};
|
||||
//_contextMongodb.InsertItem(log);
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
public async Task<bool> ExistMobileAndCompanyIsActive(string mobile)
|
||||
{
|
||||
return await _repoCompany.GetAll().AnyAsync(w => w.Mobile == mobile && w.IsActive);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
20
Back/Services/servNotification.cs
Normal file
20
Back/Services/servNotification.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using Back.Data.Contracts;
|
||||
using Back.Data.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Back.Services
|
||||
{
|
||||
public class servNotification
|
||||
{
|
||||
private readonly IAsyncRepository<Notification> _NotificationRepo;
|
||||
|
||||
public servNotification(IAsyncRepository<Notification> NotificationRepo)
|
||||
{
|
||||
_NotificationRepo = NotificationRepo;
|
||||
}
|
||||
public async Task<List<Notification>> GetNotifications()
|
||||
{
|
||||
return await _NotificationRepo.Get(w=>w.Status).ToListAsync();
|
||||
}
|
||||
}
|
||||
}
|
117
Back/Services/servPermission.cs
Normal file
117
Back/Services/servPermission.cs
Normal file
@@ -0,0 +1,117 @@
|
||||
using Back.Data.Contracts;
|
||||
using Back.Data.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Back.Services
|
||||
{
|
||||
public class servPermission
|
||||
{
|
||||
private readonly IAsyncRepository<Permission> _repoPermission;
|
||||
private readonly IAsyncRepository<PermissionPeriod> _repoPermissionPeriod;
|
||||
private readonly IAsyncRepository<RolUser> _repoRolUser;
|
||||
private readonly IAsyncRepository<PermissionUser> _repoPermissionUser;
|
||||
public servPermission(IAsyncRepository<Permission> repoPermission, IAsyncRepository<PermissionPeriod> repoPermissionPeriod
|
||||
, IAsyncRepository<RolUser> repoRolUser, IAsyncRepository<PermissionUser> repoPermissionUser)
|
||||
{
|
||||
_repoPermission = repoPermission;
|
||||
_repoPermissionPeriod = repoPermissionPeriod;
|
||||
_repoPermissionUser = repoPermissionUser;
|
||||
_repoRolUser= repoRolUser;
|
||||
}
|
||||
public async Task<List<Permission>> GetChildPermission(int PermissionID)
|
||||
{
|
||||
return await _repoPermission.Get(w => w.ParentID == PermissionID).ToListAsync();
|
||||
}
|
||||
public async Task<List<Permission>> GetPermissions()
|
||||
{
|
||||
return await _repoPermission.GetAll().ToListAsync();
|
||||
}
|
||||
public async Task<RolUser> AddRolUser(RolUser rolUser)
|
||||
{
|
||||
//SysLog log = new SysLog()
|
||||
//{
|
||||
// TraceIdentifierID = _httpContextAccessor.HttpContext.TraceIdentifier,
|
||||
// Datetime = DateTime.Now.ConvertMiladiToShamsi(),
|
||||
// Method = $"{_httpContextAccessor.HttpContext.Request.Method}/{this.GetType().FullName}/AddRolUser",
|
||||
// Value = "*" + JsonConvert.SerializeObject(rolUser),
|
||||
// Route = _httpContextAccessor.HttpContext.Request.Path,
|
||||
// Type = "User"
|
||||
//};
|
||||
//_contextMongodb.InsertItem(log);
|
||||
return await _repoRolUser.AddAsync(rolUser);
|
||||
}
|
||||
public async Task<bool> AddRangePermissionPeriodByCompany(IEnumerable<PermissionPeriod> permissions)
|
||||
{
|
||||
try
|
||||
{
|
||||
return await _repoPermissionPeriod.AddRangeAsync(permissions.ToList())/*.Wait()*/;
|
||||
//SysLog log = new SysLog()
|
||||
//{
|
||||
// TraceIdentifierID = _httpContextAccessor.HttpContext.TraceIdentifier,
|
||||
// Datetime = DateTime.Now.ConvertMiladiToShamsi(),
|
||||
// Method = $"{_httpContextAccessor.HttpContext.Request.Method}/{this.GetType().FullName}/AddRangePermissionPeriodByCompany",
|
||||
// Value = JsonConvert.SerializeObject(permissions),
|
||||
// Route = _httpContextAccessor.HttpContext.Request.Path,
|
||||
// Type = "User"
|
||||
//};
|
||||
//_contextMongodb.InsertItem(log);
|
||||
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
//SysLog log = new SysLog()
|
||||
//{
|
||||
// TraceIdentifierID = _httpContextAccessor.HttpContext.TraceIdentifier,
|
||||
// Datetime = DateTime.Now.ConvertMiladiToShamsi(),
|
||||
// Method = $"{_httpContextAccessor.HttpContext.Request.Method}/{this.GetType().FullName}/AddRangePermissionPeriodByCompany",
|
||||
// Value = ex.Message,
|
||||
// Route = _httpContextAccessor.HttpContext.Request.Path,
|
||||
// Type = "catch"
|
||||
//};
|
||||
//_contextMongodb.InsertItem(log);
|
||||
return false;
|
||||
|
||||
}
|
||||
}
|
||||
public async Task<bool> AddPermissionUser(int RolUserID, int[] PermissionIDs)
|
||||
{
|
||||
try
|
||||
{
|
||||
List<PermissionUser> permissionUsers = new List<PermissionUser>();
|
||||
foreach (int permissionID in PermissionIDs)
|
||||
permissionUsers.Add(new PermissionUser() { PermissionID=permissionID,RolUserID= RolUserID });
|
||||
|
||||
return await _repoPermissionUser.AddRangeAsync(permissionUsers);
|
||||
|
||||
//SysLog log = new SysLog()
|
||||
//{
|
||||
// TraceIdentifierID = _httpContextAccessor.HttpContext.TraceIdentifier,
|
||||
// Datetime = DateTime.Now.ConvertMiladiToShamsi(),
|
||||
// Method = $"{_httpContextAccessor.HttpContext.Request.Method}/{this.GetType().FullName}/AddPermissionUser",
|
||||
// Value = RolUserID+" "+JsonConvert.SerializeObject(PermissionIDs),
|
||||
// Route = _httpContextAccessor.HttpContext.Request.Path,
|
||||
// Type = "User"
|
||||
//};
|
||||
//_contextMongodb.InsertItem(log);
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
//SysLog log = new SysLog()
|
||||
//{
|
||||
// TraceIdentifierID = _httpContextAccessor.HttpContext.TraceIdentifier,
|
||||
// Datetime = DateTime.Now.ConvertMiladiToShamsi(),
|
||||
// Method = $"{_httpContextAccessor.HttpContext.Request.Method}/{this.GetType().FullName}/AddPermissionUser",
|
||||
// Value = ex.Message,
|
||||
// Route = _httpContextAccessor.HttpContext.Request.Path,
|
||||
// Type = "catch"
|
||||
//};
|
||||
//_contextMongodb.InsertItem(log);
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
14
Back/Services/servSendMsg.cs
Normal file
14
Back/Services/servSendMsg.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
namespace Back.Services
|
||||
{
|
||||
public class servSendMsg
|
||||
{
|
||||
private readonly mpNuget.RestClient _restClient;
|
||||
public servSendMsg(mpNuget.RestClient restClient)=> _restClient = restClient;
|
||||
private void SendMsgByPatern(string Text, string To, int bodyID) {/*_restClient.SendByBaseNumber(Text, To, bodyID);*/ }
|
||||
private void SendMsg(string Text, string To)=> _restClient.Send(To, "50004001660045", Text, false);
|
||||
public void Authentication(string to,string code) => SendMsgByPatern(code, to, 0);
|
||||
public void SuccessfulRegistration(string to, string code) => SendMsgByPatern(code, to, 1);
|
||||
public void SuccessfulPayment(string to, string code) => SendMsgByPatern(code, to, 2);
|
||||
// public void firstEntry(string to, string code) => SendMsgByPatern(code, to, 3);
|
||||
}
|
||||
}
|
286
Back/Services/servUser.cs
Normal file
286
Back/Services/servUser.cs
Normal file
@@ -0,0 +1,286 @@
|
||||
using Back.Common;
|
||||
using Back.Data.Contracts;
|
||||
using Back.Data.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.IdentityModel.Tokens;
|
||||
using Shared.DTOs;
|
||||
using System.IdentityModel.Tokens.Jwt;
|
||||
using System.Security.Claims;
|
||||
using System.Text;
|
||||
|
||||
namespace Back.Services
|
||||
{
|
||||
public class servUser
|
||||
{
|
||||
private readonly IConfiguration _configuration;
|
||||
private readonly CheckPermission _checkPermission;
|
||||
private readonly servPermission _servPermission;
|
||||
private readonly servNotification _servNotification;
|
||||
private readonly IAsyncRepository<User> _RepoUser;
|
||||
private readonly IAsyncRepository<PermissionPeriod> _RepoPermissionPeriod;
|
||||
public servUser(IConfiguration configuration,
|
||||
CheckPermission checkPermission, servPermission servPermission
|
||||
, servNotification servNotification, IAsyncRepository<User> RepoUser, IAsyncRepository<PermissionPeriod> RepoPermissionPeriod)
|
||||
{
|
||||
_configuration = configuration;
|
||||
_checkPermission = checkPermission;
|
||||
_servPermission = servPermission;
|
||||
_servNotification = servNotification;
|
||||
_RepoUser = RepoUser;
|
||||
_RepoPermissionPeriod = RepoPermissionPeriod;
|
||||
}
|
||||
public async Task<User?> GetUserByUserNameAndPassword(string UserName, string Password)
|
||||
{
|
||||
return await _RepoUser.Get(w => w.Username == UserName && w.Password == Password.encrypted() && w.IsActive)
|
||||
.Include(i => i.RolUsers)
|
||||
.ThenInclude(ti => ti.rolePermissions)
|
||||
.Include(i => i.RolUsers)
|
||||
.ThenInclude(ti=>ti.Company)
|
||||
.ThenInclude(ti => ti.PermissionPeriods)
|
||||
.ThenInclude(ti => ti.Permission)
|
||||
.Include(ti=>ti.RolUsers)
|
||||
.ThenInclude(ti => ti.Company)
|
||||
.ThenInclude(ti => ti.PermissionPeriods)
|
||||
.ThenInclude(ti => ti.CalculationType)
|
||||
.FirstOrDefaultAsync();
|
||||
}
|
||||
public async Task<UserAuthenticationDTO?> UserAuthentication(string UserNameORUserID, string Password="")
|
||||
{
|
||||
UserAuthenticationDTO ret = new UserAuthenticationDTO();
|
||||
User? user = null;
|
||||
|
||||
if (string.IsNullOrEmpty(Password) && int.TryParse(UserNameORUserID,out int UserID))
|
||||
user = await GetUserByUserID(UserID);
|
||||
else
|
||||
user =await GetUserByUserNameAndPassword(UserNameORUserID, Password);
|
||||
|
||||
if (user == null)
|
||||
return null;
|
||||
ret.Token =await CerateToken(user.ID, user.Username);
|
||||
ret.FullName = user.Fullname;
|
||||
ret.Photo = user.Photo==null ? null : Convert.ToBase64String(user.Photo);
|
||||
foreach (var rol in user.RolUsers)
|
||||
{
|
||||
if (!rol.Company.IsActive)
|
||||
continue;
|
||||
|
||||
List<PermissionAuthenticationDTO> permissions = new List<PermissionAuthenticationDTO>();
|
||||
foreach (var per in rol.Company.PermissionPeriods)
|
||||
{
|
||||
bool _accessibility = await _checkPermission.AllowPermission(user.ID, rol.CompanyID, per.Permission.ID);
|
||||
|
||||
#region Child
|
||||
|
||||
List<Permission> Chidpermissions = _accessibility ? await _servPermission.GetChildPermission(per.Permission.ID):new List<Permission>();
|
||||
List<PermissionAuthenticationDTO> ChildpermissionAuthenticationDTOs = new List<PermissionAuthenticationDTO>();
|
||||
foreach (Permission childper in Chidpermissions)
|
||||
{
|
||||
bool _childaccessibility = await _checkPermission.AllowPermission(user.ID, rol.CompanyID, childper.ID);
|
||||
PermissionAuthenticationDTO ChildpermissionAuthenticationDTO = new PermissionAuthenticationDTO
|
||||
{
|
||||
ID = childper.ID,
|
||||
ParentID = childper.ParentID,
|
||||
Title = childper.Title,
|
||||
accessibility = _childaccessibility,
|
||||
//TODO
|
||||
ChildPermissions = null
|
||||
};
|
||||
ChildpermissionAuthenticationDTOs.Add(ChildpermissionAuthenticationDTO);
|
||||
}
|
||||
#endregion
|
||||
|
||||
PermissionAuthenticationDTO permissionAuthenticationDTO = new PermissionAuthenticationDTO
|
||||
{
|
||||
ID = per.Permission.ID,
|
||||
ParentID = per.Permission.ParentID,
|
||||
Title = per.Permission.Title,
|
||||
accessibility = _accessibility,
|
||||
//TODO
|
||||
ChildPermissions = ChildpermissionAuthenticationDTOs
|
||||
|
||||
//Period=new PeriodDTO()
|
||||
//{
|
||||
// CalculationTypeID = rol.Company.PermissionPeriods.Where(w => w.PermissionID == per.ID).Select(s => s.CalculationType.ID).FirstOrDefault(),
|
||||
// CalculationTypeTitle = rol.Company.PermissionPeriods.Where(w => w.PermissionID == per.ID).Select(s => s.CalculationType.Title).FirstOrDefault(),
|
||||
// RemainingAmount = rol.Company.PermissionPeriods.Where(w => w.PermissionID == per.ID).Select(s => s.RemainingAmount).FirstOrDefault(),
|
||||
// TotalAmount = rol.Company.PermissionPeriods.Where(w => w.PermissionID == per.ID).Select(s => s.TotalAmount).FirstOrDefault()
|
||||
//}
|
||||
|
||||
};
|
||||
permissions.Add(permissionAuthenticationDTO);
|
||||
}
|
||||
|
||||
ret.Companies.Add(new CompanyAuthenticationDTO
|
||||
{
|
||||
ID = rol.CompanyID,
|
||||
Name = rol.Company.Name,
|
||||
IsAdmin = rol.IsAdmin,
|
||||
Logo= rol.Company.Logo == null ? null : Convert.ToBase64String(rol.Company.Logo)
|
||||
|
||||
/*, permissions = permissions*/
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
public async Task<User> AddUser(User item)
|
||||
{
|
||||
//_contextMongodb.InsertItem(new SysLog()
|
||||
//{
|
||||
// TraceIdentifierID = _httpContextAccessor.HttpContext.TraceIdentifier,
|
||||
// Datetime = DateTime.Now.ConvertMiladiToShamsi(),
|
||||
// Method = $"{_httpContextAccessor.HttpContext.Request.Method}/{this.GetType().FullName}/AddUser",
|
||||
// Value = JsonConvert.SerializeObject(item),
|
||||
// Route = _httpContextAccessor.HttpContext.Request.Path,
|
||||
// Type = "User"
|
||||
//});
|
||||
return await _RepoUser.AddAsync(item);
|
||||
}
|
||||
public async Task<bool> ExistUser(string UserName)
|
||||
{
|
||||
|
||||
return await _RepoUser.GetAll().AnyAsync(w=>w.Username==UserName);
|
||||
|
||||
}
|
||||
public async Task<User> GetUserByUsername(string UserName)
|
||||
{
|
||||
return await _RepoUser.Get(w => w.Username == UserName).FirstOrDefaultAsync();
|
||||
}
|
||||
public async Task<User?> GetUserByUserID(int UserID)
|
||||
{
|
||||
return await _RepoUser.Get(w => w.ID == UserID).FirstOrDefaultAsync();
|
||||
}
|
||||
public async void SetTokenAndDateLogininDB(int UserID,string Token)
|
||||
{
|
||||
var user = await GetUserByUserID(UserID);
|
||||
if (user != null)
|
||||
{
|
||||
user.Token = Token;
|
||||
user.DateLastLogin=DateTime.Now.ConvertMiladiToShamsi();
|
||||
await _RepoUser.UpdateAsync(user);
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<DashBoardDTO> GetDashBoard(int CompanyID,int UserID)
|
||||
{
|
||||
DashBoardDTO request=new DashBoardDTO();
|
||||
var period=await _RepoPermissionPeriod
|
||||
.Get(w=>w.CompanyID==CompanyID && (!w.IsLocked.HasValue || !w.IsLocked.Value)).ToListAsync();
|
||||
foreach (var item in period)
|
||||
{
|
||||
request.AlistofServices.Add(new ServiceInDashBoardDTO
|
||||
{
|
||||
PermissionID= item.PermissionID,
|
||||
PermissionName = item.Permission.Title,
|
||||
CalTypeID= item.CalculationTypeID,
|
||||
CalTypeTitle = item.CalculationType.Title,
|
||||
Total = item.CalculationTypeID == 1 ? item.TotalAmount.ToString() :"",
|
||||
Remaining = item.CalculationTypeID == 1 ? item.RemainingAmount.ToString()
|
||||
: item.CalculationTypeID== 2 ? "" : item.RemainingAmount.ToString().ShamciToFormatShamci()
|
||||
});
|
||||
}
|
||||
request.LastLoginDate= _RepoUser.Get(w=>w.ID==UserID).Select(s=>s.DateLastLogin).FirstOrDefault();
|
||||
if(!string.IsNullOrEmpty(request.LastLoginDate))
|
||||
request.LastLoginDate.ShamciToFormatShamci();
|
||||
|
||||
var user = await GetUserByUserID(UserID);
|
||||
if (user.Mobile == user.Username)
|
||||
request.Warning.Add(new AlertDTO { Status=0,Message= "موبایل و نام کاربری بهتر است شبیه هم نباشند" });
|
||||
if (user.Mobile.encrypted() == user.Password)
|
||||
request.Warning.Add(new AlertDTO { Status = 0, Message = "موبایل و کلمه عبور بهتر است شبیه هم نباشند" });
|
||||
var Company = user.RolUsers.Where(w=>w.CompanyID== CompanyID).Select(s=>s.Company).FirstOrDefault();
|
||||
if (Company!=null)
|
||||
{
|
||||
if (string.IsNullOrEmpty(Company.Email) || string.IsNullOrEmpty(Company.Phone)
|
||||
|| string.IsNullOrEmpty(Company.EconomicCode) || string.IsNullOrEmpty(Company.UniqeMemory)
|
||||
|| string.IsNullOrEmpty(Company.PrivateKey))
|
||||
{
|
||||
request.Warning.Add(new AlertDTO { Status = 0, Message = "بهتر است اطلاعات شرکت بروزرسانی شود" });
|
||||
}
|
||||
}
|
||||
var nots= await _servNotification.GetNotifications();
|
||||
if (nots.Any())
|
||||
request.Notifications= nots.Select(s=>new AlertDTO
|
||||
{
|
||||
Message=s.Message,
|
||||
Status=s.Type,
|
||||
Path=s.Path,
|
||||
ViewSize=s.ViewSize
|
||||
}).ToList();
|
||||
return request;
|
||||
}
|
||||
public async Task<User> UpdateUser(User user)
|
||||
{
|
||||
//_contextMongodb.InsertItem(new SysLog()
|
||||
//{
|
||||
// TraceIdentifierID = _httpContextAccessor.HttpContext.TraceIdentifier,
|
||||
// Datetime = DateTime.Now.ConvertMiladiToShamsi(),
|
||||
// Method = $"{_httpContextAccessor.HttpContext.Request.Method}/{this.GetType().FullName}/UpdateUser",
|
||||
// Value = JsonConvert.SerializeObject(user),
|
||||
// Route = _httpContextAccessor.HttpContext.Request.Path,
|
||||
// Type = "User"
|
||||
//});
|
||||
return await _RepoUser.UpdateByObjAsync(user);
|
||||
}
|
||||
//--------internal
|
||||
private async Task<string> CerateToken(int UserId, string UserName)
|
||||
{
|
||||
string Jwt_Lifetime_Minutes = "";
|
||||
try
|
||||
{
|
||||
Jwt_Lifetime_Minutes = _configuration["Fixedvalues:Jwt_Lifetime_Minutes"].ToString();
|
||||
if (string.IsNullOrEmpty(Jwt_Lifetime_Minutes))
|
||||
Jwt_Lifetime_Minutes = "60";
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
//SysLog log = new SysLog()
|
||||
//{
|
||||
// TraceIdentifierID = _httpContextAccessor.HttpContext.TraceIdentifier,
|
||||
// Datetime = DateTime.Now.ConvertMiladiToShamsi(),
|
||||
// Method = $"{_httpContextAccessor.HttpContext.Request.Method}/{this.GetType().FullName}/CerateToken",
|
||||
// Value = ex.Message,
|
||||
// Route = _httpContextAccessor.HttpContext.Request.Path,
|
||||
// Type = "catch"
|
||||
//};
|
||||
//_contextMongodb.InsertItem(log);
|
||||
Jwt_Lifetime_Minutes = "60";
|
||||
//To DO
|
||||
}
|
||||
|
||||
#region CreateToken
|
||||
var securityKey = new SymmetricSecurityKey(
|
||||
Encoding.ASCII.GetBytes(Fixedvalues.SecretForKey)
|
||||
);
|
||||
var signingCredentials = new SigningCredentials(
|
||||
securityKey, SecurityAlgorithms.HmacSha256
|
||||
);
|
||||
var claimsForToken = new List<Claim>();
|
||||
claimsForToken.Add(new Claim("UserID", UserId.ToString()));
|
||||
claimsForToken.Add(new Claim(ClaimTypes.NameIdentifier, UserName));
|
||||
|
||||
var jwtSecurityToke = new JwtSecurityToken(
|
||||
Fixedvalues.Issuer, Fixedvalues.Audience, claimsForToken,
|
||||
DateTime.Now, DateTime.Now.AddMinutes(Convert.ToInt32(Jwt_Lifetime_Minutes)), signingCredentials);
|
||||
|
||||
|
||||
string Token = new JwtSecurityTokenHandler()
|
||||
.WriteToken(jwtSecurityToke);
|
||||
SetTokenAndDateLogininDB(UserId, Token);
|
||||
//_contextMongodb.InsertItem(new SysLog()
|
||||
//{
|
||||
// TraceIdentifierID = _httpContextAccessor.HttpContext.TraceIdentifier,
|
||||
// Datetime = DateTime.Now.ConvertMiladiToShamsi(),
|
||||
// Method = $"{_httpContextAccessor.HttpContext.Request.Method}/{this.GetType().FullName}/CerateToken",
|
||||
// Value = UserId + " " + UserName+"=> "+Token,
|
||||
// Route = _httpContextAccessor.HttpContext.Request.Path,
|
||||
// Type = "User"
|
||||
//});
|
||||
return Token;
|
||||
#endregion
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
21
Back/Validations/CompanyRegistrationValidation.cs
Normal file
21
Back/Validations/CompanyRegistrationValidation.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
using Back.Services;
|
||||
using FluentValidation;
|
||||
using Shared.DTOs;
|
||||
|
||||
namespace Back.Validations
|
||||
{
|
||||
public class CompanyRegistrationValidation : AbstractValidator<CompanyRegistrationDTO>
|
||||
{
|
||||
public CompanyRegistrationValidation(servCompany servCompany)
|
||||
{
|
||||
CascadeMode = CascadeMode.Stop;
|
||||
RuleFor(m => m.Mobile)
|
||||
.NotEmpty().WithMessage("موبایل نمی تواند باشد")
|
||||
.NotNull().WithMessage("موبایل نمی تواند باشد")
|
||||
.Length(11).WithMessage("فرمت موبایل صحیح نمی باشد")
|
||||
.Must(m => m.StartsWith("09")).WithMessage("فرمت موبایل صحیح نمی باشد")
|
||||
.Must(mo=> !servCompany.ExistMobileAndCompanyIsActive(mo).Result)
|
||||
.WithMessage("این موبایل قبلا ثبت شده");
|
||||
}
|
||||
}
|
||||
}
|
8
Shared/DTOs/Authentication.cs
Normal file
8
Shared/DTOs/Authentication.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
namespace Shared.DTOs
|
||||
{
|
||||
public class Authentication
|
||||
{
|
||||
public string Username { get; set; }
|
||||
public string Password { get; set; }
|
||||
}
|
||||
}
|
12
Shared/DTOs/CompanyAuthenticationDTO.cs
Normal file
12
Shared/DTOs/CompanyAuthenticationDTO.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
namespace Shared.DTOs
|
||||
{
|
||||
public class CompanyAuthenticationDTO
|
||||
{
|
||||
public int ID { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string? Logo { get; set; }
|
||||
public bool IsAdmin { get; set; }
|
||||
// public ICollection<PermissionAuthenticationDTO> permissions { get; set; } = new List<PermissionAuthenticationDTO>();
|
||||
|
||||
}
|
||||
}
|
17
Shared/DTOs/CompanyDTO.cs
Normal file
17
Shared/DTOs/CompanyDTO.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
namespace Shared.DTOs
|
||||
{
|
||||
public class CompanyDTO
|
||||
{
|
||||
public int ID { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string? Email { get; set; }
|
||||
public string? Phone { get; set; }
|
||||
public string Mobile { get; set; }
|
||||
public string BranchID { get; set; }
|
||||
public string? EconomicCode { get; set; }
|
||||
public string? UniqeMemory { get; set; }
|
||||
public string? PrivateKey { get; set; }
|
||||
public string? Logo { get; set; }
|
||||
|
||||
}
|
||||
}
|
13
Shared/DTOs/CompanyRegistrationDTO.cs
Normal file
13
Shared/DTOs/CompanyRegistrationDTO.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace Shared.DTOs
|
||||
{
|
||||
public class CompanyRegistrationDTO
|
||||
{
|
||||
[MinLength(5)]
|
||||
public string CompanyName { get; set; }
|
||||
public string FullnameUser { get { return CompanyName; } }
|
||||
public string Mobile { get; set; }
|
||||
public string Username { get { return Mobile; } }
|
||||
}
|
||||
}
|
28
Shared/DTOs/DashBoardDTO.cs
Normal file
28
Shared/DTOs/DashBoardDTO.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Shared.DTOs
|
||||
{
|
||||
public class AlertDTO
|
||||
{
|
||||
public int Status { get; set; }
|
||||
public string Message { get; set; }
|
||||
public string? Path { get; set; }
|
||||
public string? ViewSize { get; set; }
|
||||
}
|
||||
public class DashBoardDTO
|
||||
{
|
||||
public string? LastLoginDate { get; set; }
|
||||
public List<ServiceInDashBoardDTO> AlistofServices { get; set; }=new List<ServiceInDashBoardDTO>();
|
||||
public List<AlertDTO> Warning { get; set; } = new List<AlertDTO>();
|
||||
public List<AlertDTO> Notifications { get; set; } = new List<AlertDTO>();
|
||||
}
|
||||
public class ServiceInDashBoardDTO
|
||||
{
|
||||
public int PermissionID { get; set; }
|
||||
public string PermissionName { get; set; }
|
||||
public int CalTypeID { get; set; }
|
||||
public string CalTypeTitle { get; set; }
|
||||
public string Total { get; set; }
|
||||
public string Remaining { get; set; }
|
||||
}
|
||||
}
|
11
Shared/DTOs/PermissionAuthenticationDTO.cs
Normal file
11
Shared/DTOs/PermissionAuthenticationDTO.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
namespace Shared.DTOs
|
||||
{
|
||||
public class PermissionAuthenticationDTO
|
||||
{
|
||||
public int ID { get; set; }
|
||||
public int ParentID { get; set; }
|
||||
public string Title { get; set; }
|
||||
public bool accessibility { get; set; }
|
||||
public List<PermissionAuthenticationDTO> ChildPermissions { get; set; }
|
||||
}
|
||||
}
|
14
Shared/DTOs/UserAuthenticationDTO.cs
Normal file
14
Shared/DTOs/UserAuthenticationDTO.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
using System.Security.Principal;
|
||||
|
||||
namespace Shared.DTOs
|
||||
{
|
||||
public class UserAuthenticationDTO
|
||||
{
|
||||
|
||||
public string FullName { get; set; }
|
||||
public string Token { get; set; }
|
||||
public string Photo { get; set; }
|
||||
public ICollection<CompanyAuthenticationDTO> Companies { get; set; } = new List<CompanyAuthenticationDTO>();
|
||||
|
||||
}
|
||||
}
|
@@ -42,13 +42,13 @@
|
||||
<div class="row gx-20">
|
||||
<div class="col-12">
|
||||
<div class="postbox__comment-input mb-30">
|
||||
<InputText @bind-Value="model.FullName" id="FullName" type="text" class="inputText" required="" />
|
||||
<InputText onkeydown="@OnClearmessageStore" @bind-Value="model.FullName" id="FullName" type="text" class="inputText" required="" />
|
||||
<span class="floating-label">نام شما</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-12">
|
||||
<div class="postbox__comment-input mb-35">
|
||||
<InputText @bind-Value="model.Mobile" id="Mobile" type="text" class="inputText" required=""/>
|
||||
<InputText onkeydown="@OnClearmessageStore" @bind-Value="model.Mobile" id="Mobile" type="text" class="inputText" required="" />
|
||||
<span class="floating-label">موبایل</span>
|
||||
</div>
|
||||
</div>
|
||||
@@ -103,6 +103,7 @@
|
||||
}
|
||||
}
|
||||
@functions{
|
||||
private async Task OnClearmessageStore() => messageStore?.Clear();
|
||||
private async Task newTicket(){
|
||||
|
||||
var request = await _hc.PostAsJsonAsync("Ticket/NewTicketNoAuthentication", model);
|
||||
|
@@ -1,4 +1,7 @@
|
||||
@page "/Register"
|
||||
@using Shared.DTOs
|
||||
@inject HttpClient _hc
|
||||
@inject NavigationManager nav
|
||||
<PageTitle>ثبت نام</PageTitle>
|
||||
<main>
|
||||
|
||||
@@ -10,9 +13,9 @@
|
||||
</div>
|
||||
<div class="signin-banner-left-wrap">
|
||||
<div class="signin-banner-title-box mb-100">
|
||||
<h4 class="signin-banner-title">
|
||||
خوش آمدید به <br>
|
||||
فضای کاری اختصاصی خودتان
|
||||
<br />
|
||||
<h4 class="signin-banner-title" style="color:black">
|
||||
برای استفاده از همه بخش ها <br /> ثبت نام کنید
|
||||
</h4>
|
||||
</div>
|
||||
<div class="signin-banner-img-box position-relative">
|
||||
@@ -39,71 +42,35 @@
|
||||
|
||||
<div class="signin-banner-from-box">
|
||||
|
||||
<form action="#">
|
||||
<EditForm EditContext="editContext" OnValidSubmit="OnRegisterClick">
|
||||
<DataAnnotationsValidator />
|
||||
<div class="postbox__comment-input mb-35">
|
||||
<ValidationMessage For="()=>model.CompanyName" />
|
||||
<ValidationMessage For="()=>model.Mobile" />
|
||||
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="postbox__comment-input mb-30">
|
||||
<input type="text" class="inputText" required="">
|
||||
<InputText onkeydown="@OnClearmessageStore" @bind-Value="model.CompanyName" id="CompanyName" type="text" class="inputText" required="" />
|
||||
<span class="floating-label">نام کامل</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-12">
|
||||
<div class="postbox__comment-input mb-30">
|
||||
<input type="text" class="inputText" required="">
|
||||
<span class="floating-label">ایمیل شما</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-12">
|
||||
<div class="postbox__comment-input mb-30">
|
||||
<input id="myInput" class="inputText password" type="password" required="">
|
||||
<span class="floating-label">گذرواژه</span>
|
||||
<span id="click" class="eye-btn">
|
||||
<span class="eye-on">
|
||||
<svg width="20" height="17" viewBox="0 0 20 17" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path opacity="0.5" d="M2.1474 11.1661C1.38247 10.1723 1 9.67544 1 8.2C1 6.72456 1.38247 6.22767 2.1474 5.2339C3.67477 3.2496 6.2363 1 10 1C13.7637 1 16.3252 3.2496 17.8526 5.2339C18.6175 6.22767 19 6.72456 19 8.2C19 9.67544 18.6175 10.1723 17.8526 11.1661C16.3252 13.1504 13.7637 15.4 10 15.4C6.2363 15.4 3.67477 13.1504 2.1474 11.1661Z" stroke="#1C274C" stroke-width="1.5"></path>
|
||||
<path d="M12.6969 8.2C12.6969 9.69117 11.488 10.9 9.99687 10.9C8.50571 10.9 7.29688 9.69117 7.29688 8.2C7.29688 6.70883 8.50571 5.5 9.99687 5.5C11.488 5.5 12.6969 6.70883 12.6969 8.2Z" stroke="#1C274C" stroke-width="1.5"></path>
|
||||
</svg>
|
||||
</span>
|
||||
<span class="eye-off">
|
||||
<svg width="18" height="18" viewBox="0 0 25 25" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<g clip-path="url(#clip0_2547_24206)">
|
||||
<path d="M18.813 18.9113C17.1036 20.2143 15.0222 20.9362 12.873 20.9713C5.87305 20.9713 1.87305 12.9713 1.87305 12.9713C3.11694 10.6532 4.84218 8.62795 6.93305 7.03134M10.773 5.21134C11.4614 5.05022 12.1661 4.96968 12.873 4.97134C19.873 4.97134 23.873 12.9713 23.873 12.9713C23.266 14.1069 22.5421 15.1761 21.713 16.1613M14.993 15.0913C14.7184 15.3861 14.3872 15.6225 14.0192 15.7865C13.6512 15.9504 13.2539 16.0386 12.8511 16.0457C12.4483 16.0528 12.0482 15.9787 11.6747 15.8278C11.3011 15.6769 10.9618 15.4524 10.6769 15.1675C10.392 14.8826 10.1674 14.5433 10.0166 14.1697C9.86567 13.7962 9.79157 13.3961 9.79868 12.9932C9.80579 12.5904 9.89396 12.1932 10.0579 11.8252C10.2219 11.4572 10.4583 11.126 10.753 10.8513" stroke="black" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path>
|
||||
<path d="M1.87305 1.97131L23.873 23.9713" stroke="black" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path>
|
||||
</g>
|
||||
<defs>
|
||||
<clipPath id="clip0_2547_24206">
|
||||
<rect width="24" height="24" fill="white" transform="translate(0.873047 0.971313)"></rect>
|
||||
</clipPath>
|
||||
</defs>
|
||||
</svg>
|
||||
</span>
|
||||
</span>
|
||||
<InputText onkeydown="@OnClearmessageStore" @bind-Value="model.Mobile" id="Mobile" type="text" class="inputText" required="" />
|
||||
<span class="floating-label">موبایل</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<div class="signin-banner-form-remember">
|
||||
<div class="row">
|
||||
<div class="col-6">
|
||||
<div class="postbox__comment-agree">
|
||||
<div class="form-check">
|
||||
<input class="form-check-input" type="checkbox" value="" id="flexCheckDefault">
|
||||
<label class="form-check-label" for="flexCheckDefault">
|
||||
مرا به یاد بسپار
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<div class="postbox__forget text-end">
|
||||
<a href="#">رمز عبور را فراموش کرده اید؟</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="signin-banner-from-btn mb-20">
|
||||
<button type="submit" class="signin-btn ">ثبت نام</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="signin-banner-from-btn mb-20">
|
||||
<button class="signin-btn ">ثبت نام</button>
|
||||
|
||||
</EditForm>
|
||||
|
||||
|
||||
<div class="signin-banner-from-register">
|
||||
<NavLink href="Sign-in">ثبت نام کردید؟ <span>ورود</span></NavLink>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -113,5 +80,35 @@
|
||||
</main>
|
||||
|
||||
@code {
|
||||
string type = "CompanyRegistration";
|
||||
private EditContext? editContext;
|
||||
[SupplyParameterFromForm]
|
||||
private CompanyRegistrationDTO? model { get; set; } = new CompanyRegistrationDTO();
|
||||
private ValidationMessageStore? messageStore;
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
editContext = new EditContext(model);
|
||||
messageStore = new(editContext);
|
||||
await base.OnInitializedAsync();
|
||||
}
|
||||
}
|
||||
@functions{
|
||||
private async Task OnClearmessageStore() => messageStore?.Clear();
|
||||
private async Task OnRegisterClick()
|
||||
{
|
||||
var request = await _hc.PostAsJsonAsync("Base/CompanyRegistration", model);
|
||||
if (request.IsSuccessStatusCode)
|
||||
{
|
||||
messageStore?.Clear();
|
||||
var VerificationID = await request.Content.ReadFromJsonAsync<int>();
|
||||
nav.NavigateTo($"Verification/{VerificationID}");
|
||||
}
|
||||
else
|
||||
{
|
||||
var error = await request.Content.ReadFromJsonAsync<List<string>>();
|
||||
messageStore?.Add(() => model.Mobile, error);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@@ -9,9 +9,9 @@ builder.RootComponents.Add<HeadOutlet>("head::after");
|
||||
builder.Services.AddBlazorBootstrap();
|
||||
|
||||
|
||||
builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri("https://localhost:7075/api/") });
|
||||
//builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri("https://localhost:7075/api/") });
|
||||
|
||||
//builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri("http://localhost:5271/api/") });
|
||||
builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri("http://localhost:5271/api/") });
|
||||
|
||||
CultureInfo.DefaultThreadCurrentCulture = new CultureInfo("fa-Ir");
|
||||
|
||||
|
Reference in New Issue
Block a user