....
This commit is contained in:
16
Back/Common/DTOs/PagingDto.cs
Normal file
16
Back/Common/DTOs/PagingDto.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
namespace Back.Common.ViewModels
|
||||
{
|
||||
public class PagingDto<T>
|
||||
{
|
||||
public PagingDto(int RowCount, int pageCount, List<T> list)
|
||||
{
|
||||
this.RowCount = RowCount;
|
||||
this.list = list;
|
||||
PageCount = pageCount;
|
||||
|
||||
}
|
||||
public int RowCount { get; set; }
|
||||
public int PageCount { get; set; }
|
||||
public List<T> list { get; set; }
|
||||
}
|
||||
}
|
17
Back/Common/Enums/CustomerType.cs
Normal file
17
Back/Common/Enums/CustomerType.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace Back.Common.Enums
|
||||
{
|
||||
public enum CustomerType:int
|
||||
{
|
||||
[Display(Name = "حقیقی")]
|
||||
genuine = 1,
|
||||
[Display(Name = "حقوقی")]
|
||||
legal = 2,
|
||||
[Display(Name = "مشارکت مدنی")]
|
||||
CivilPartnership = 3,
|
||||
[Display(Name = "اتباع عیر ایرانی")]
|
||||
NonIranianNationals = 4
|
||||
|
||||
}
|
||||
}
|
25
Back/Common/Enums/InvoiceType.cs
Normal file
25
Back/Common/Enums/InvoiceType.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace Back.Common.Enums
|
||||
{
|
||||
public enum InvoiceType:int
|
||||
{
|
||||
[Display(Name = "پیشنهاد قیمت")]
|
||||
Bidding=10,
|
||||
//[Display(Name = "فاکتور")]
|
||||
//Factor=11,
|
||||
//[Display(Name = "قطعی")]
|
||||
//Final=12,
|
||||
[Display(Name = "لغو")]
|
||||
CANCEL = 0,
|
||||
[Display(Name = "فروش")]
|
||||
Sale=1,
|
||||
[Display(Name = "ابطالی")]
|
||||
Cancellation=3,
|
||||
[Display(Name = "اصلاحی")]
|
||||
Repair=2,
|
||||
[Display(Name = "برگشت از فروش")]
|
||||
BackFrmSale = 4
|
||||
|
||||
}
|
||||
}
|
21
Back/Common/Enums/SentStatus.cs
Normal file
21
Back/Common/Enums/SentStatus.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
namespace Back.Common.Enums
|
||||
{
|
||||
public enum SentStatus
|
||||
{
|
||||
|
||||
[Display(Name = "ارسال شده")]
|
||||
Send,
|
||||
[Display(Name = "موفق")]
|
||||
Successful,
|
||||
[Display(Name = "ناموفق")]
|
||||
Unsuccessful,
|
||||
[Display(Name = "در حال پردازش")]
|
||||
pending,
|
||||
[Display(Name = "نامشخص")]
|
||||
Unknown,
|
||||
[Display(Name = "یافت نشده")]
|
||||
NOT_FOUND
|
||||
|
||||
}
|
||||
}
|
12
Back/Common/Enums/SideType.cs
Normal file
12
Back/Common/Enums/SideType.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace Back.Common.Enums
|
||||
{
|
||||
public enum SideType
|
||||
{
|
||||
[Display(Name = "مشتری")]
|
||||
Customer,
|
||||
[Display(Name = "کارشناس")]
|
||||
Expert
|
||||
}
|
||||
}
|
14
Back/Common/Enums/StatusOrder.cs
Normal file
14
Back/Common/Enums/StatusOrder.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace Back.Common.Enums
|
||||
{
|
||||
public enum StatusOrder
|
||||
{
|
||||
[Display(Name = "ساخته شده")]
|
||||
Create,
|
||||
[Display(Name = "پرداخت شده")]
|
||||
Paid,
|
||||
[Display(Name = "انصراف داده شده")]
|
||||
Cancel
|
||||
}
|
||||
}
|
28
Back/Common/Enums/StatusTicket.cs
Normal file
28
Back/Common/Enums/StatusTicket.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using static Back.Common.ExclusiveAttribute;
|
||||
|
||||
namespace Back.Common.Enums
|
||||
{
|
||||
public enum StatusTicket
|
||||
{
|
||||
|
||||
[Color("00FF23")]
|
||||
[Display(Name = "فرد ناشناس")]
|
||||
unknownPerson,
|
||||
[Color("8844A3")]
|
||||
[Display(Name = "در انتظار بررسی")]
|
||||
Awaitingreview,
|
||||
[Color("2CAFE8")]
|
||||
[Display(Name = "خوانده شده/ در حال بررسی")]
|
||||
Read_Checking,
|
||||
[Color("4AB621")]
|
||||
[Display(Name = "پاسخ داده شده")]
|
||||
hasbeenanswered,
|
||||
[Color("37363E")]
|
||||
[Display(Name = "پاِیان")]
|
||||
End,
|
||||
[Color("D24249")]
|
||||
[Display(Name = "انصراف")]
|
||||
optout,
|
||||
}
|
||||
}
|
13
Back/Common/ExclusiveAttribute.cs
Normal file
13
Back/Common/ExclusiveAttribute.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
namespace Back.Common
|
||||
{
|
||||
public class ExclusiveAttribute
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.Method | AttributeTargets.Class,
|
||||
AllowMultiple = false)]
|
||||
public class ColorAttribute : Attribute
|
||||
{
|
||||
public string _ColorHex;
|
||||
public ColorAttribute(string ColorHex) => _ColorHex = ColorHex;
|
||||
}
|
||||
}
|
||||
}
|
93
Back/Common/ExtentionMethods.cs
Normal file
93
Back/Common/ExtentionMethods.cs
Normal file
@@ -0,0 +1,93 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using static Back.Common.ExclusiveAttribute;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Data;
|
||||
using System.Globalization;
|
||||
using System.Reflection;
|
||||
using System.Security.Cryptography;
|
||||
using Back.Common.ViewModels;
|
||||
|
||||
namespace Back.Common
|
||||
{
|
||||
public static class ExtentionMethods
|
||||
{
|
||||
public static string GetEnumDisplayName(this Enum enumType)
|
||||
{
|
||||
return enumType.GetType().GetMember(enumType.ToString())
|
||||
.First()
|
||||
.GetCustomAttribute<DisplayAttribute>()
|
||||
.Name;
|
||||
}
|
||||
public static string GetEnumHexColor(this Enum enumType)
|
||||
{
|
||||
return enumType.GetType().GetMember(enumType.ToString())
|
||||
.First()
|
||||
.GetCustomAttribute<ColorAttribute>()
|
||||
._ColorHex;
|
||||
}
|
||||
public static string encrypted(this string txt)
|
||||
{
|
||||
HashAlgorithm hash = new MD5CryptoServiceProvider();
|
||||
var bytes = System.Text.Encoding.UTF8.GetBytes(txt);
|
||||
var hashedBytes = hash.ComputeHash(bytes);
|
||||
|
||||
string res = BitConverter.ToString(hashedBytes).Replace("-", string.Empty);
|
||||
return res;
|
||||
}
|
||||
public static string ConvertMiladiToShamsi(this DateTime date)
|
||||
{
|
||||
PersianCalendar PersianCal = new PersianCalendar();
|
||||
return PersianCal.GetYear(date).ToString("0000") +
|
||||
PersianCal.GetMonth(date).ToString("00") +
|
||||
PersianCal.GetDayOfMonth(date).ToString("00");
|
||||
}
|
||||
public static string ShamciToFormatShamci(this string str)
|
||||
{
|
||||
if (string.IsNullOrEmpty(str)) return "";
|
||||
return str.Substring(0, 4) + "/" + str.Substring(4, 2) + "/" + str.Substring(6, 2);
|
||||
}
|
||||
public static DateTime ToMiladi(this string value)
|
||||
{
|
||||
PersianCalendar p = new PersianCalendar();
|
||||
return p.ToDateTime(Convert.ToInt32(value.Substring(0, 4)), Convert.ToInt32(value.Substring(4, 2)), Convert.ToInt32(value.Substring(6, 2)), 0, 0, 0, 0);
|
||||
}
|
||||
public static async Task<PagingDto<T>> Paging<T>(this IQueryable<T> values, int pageId, int take)
|
||||
{
|
||||
if (/*values.Count()<1000 && */pageId == 0 && take == 0)
|
||||
{
|
||||
return new PagingDto<T>(values.Count(), 1, await values.ToListAsync());
|
||||
}
|
||||
else
|
||||
{
|
||||
int skip = (pageId - 1) * take;
|
||||
int rowCount = values.Count();
|
||||
int PageCount = rowCount % take == 0 ? rowCount / take : rowCount / take + 1;
|
||||
return new PagingDto<T>(rowCount, PageCount, await values.Skip(skip).Take(take).ToListAsync());
|
||||
}
|
||||
|
||||
}
|
||||
public static System.Linq.Expressions.Expression<Func<TEntity, bool>> GetFunc<TEntity>(string Fild, string Value)
|
||||
{
|
||||
Type type = typeof(TEntity);
|
||||
// System.Linq.Expressions.Expression<Func<TEntity, bool>> convert = s => type.GetProperty(Fild) != null && s.GetType().GetProperty(Fild).GetValue(s) == Value;
|
||||
return Entity => type.GetProperty(Fild) != null && Entity.GetType().GetProperty(Fild).GetValue(Entity) == Value;
|
||||
}
|
||||
public static DataTable ConvertStringBase64toDataTable(this string value, string SheetName = null)
|
||||
{
|
||||
//try
|
||||
//{
|
||||
// MemoryStream stream1 = new MemoryStream(Convert.FromBase64String(value));
|
||||
// WorkBook workbook = WorkBook.Load(stream1);
|
||||
|
||||
// WorkSheet sheet = SheetName == null ? workbook.DefaultWorkSheet : workbook.GetWorkSheet(SheetName);
|
||||
|
||||
// return sheet.ToDataTable(true);
|
||||
//}
|
||||
//catch (Exception)
|
||||
//{
|
||||
return new DataTable();
|
||||
// }
|
||||
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user