add new metod to tools for family allowance
This commit is contained in:
@@ -32,6 +32,142 @@ public static class Tools
|
||||
public static string[] DayNames = { "شنبه", "یکشنبه", "دو شنبه", "سه شنبه", "چهار شنبه", "پنج شنبه", "جمعه" };
|
||||
public static string[] DayNamesG = { "یکشنبه", "دو شنبه", "سه شنبه", "چهار شنبه", "پنج شنبه", "جمعه", "شنبه" };
|
||||
|
||||
public static (int yearCount, int monthCount, int dayCount) GetOld(DateTime startDate, DateTime endDate)
|
||||
{
|
||||
|
||||
var startFa = startDate.ToFarsi();
|
||||
int startYear = Convert.ToInt32(startFa.Substring(0, 4));
|
||||
int startMonth = Convert.ToInt32(startFa.Substring(5, 2));
|
||||
int startDay = Convert.ToInt32(startFa.Substring(8, 2));
|
||||
var start = new PersianDateTime(startYear, startMonth, startDay);
|
||||
|
||||
|
||||
var endFa = endDate.ToFarsi();
|
||||
int endYear = Convert.ToInt32(endFa.Substring(0, 4));
|
||||
int endMonth = Convert.ToInt32(endFa.Substring(5, 2));
|
||||
int endDay = Convert.ToInt32(endFa.Substring(8, 2));
|
||||
var end = new PersianDateTime(endYear, endMonth, endDay);
|
||||
int months = 0;
|
||||
int days = 0;
|
||||
int years = 0;
|
||||
|
||||
var firstYearCounter = start.AddYears(1);
|
||||
|
||||
if (firstYearCounter > end)
|
||||
{
|
||||
start = start.AddYears(-1);
|
||||
//if (start > end)
|
||||
//{
|
||||
// start = start.AddMonths(-1);
|
||||
//}
|
||||
|
||||
var endMonthCounter = new PersianDateTime(end.Year, end.Month, start.Day);
|
||||
|
||||
for (var monthCounter = start; monthCounter <= end; monthCounter = monthCounter.AddMonths(1))
|
||||
{
|
||||
if (monthCounter <= end)
|
||||
{
|
||||
Console.ForegroundColor = ConsoleColor.Yellow;
|
||||
Console.WriteLine("month : " + monthCounter);
|
||||
months++;
|
||||
}
|
||||
|
||||
if (monthCounter.Month == end.Month)
|
||||
{
|
||||
var firstDayCounter = monthCounter.AddDays(1);
|
||||
for (var dayCounter = firstDayCounter; dayCounter <= end; dayCounter = dayCounter.AddDays(1))
|
||||
{
|
||||
if (dayCounter <= end)
|
||||
{
|
||||
days++;
|
||||
Console.ForegroundColor = ConsoleColor.Cyan;
|
||||
Console.WriteLine("day : " + dayCounter);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
months = months > 0 ? months - 1 : 0;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
for (var yearCouner = firstYearCounter; yearCouner <= end; yearCouner = yearCouner.AddYears(1))
|
||||
{
|
||||
|
||||
if (yearCouner.Year <= end.Year)
|
||||
{
|
||||
years++;
|
||||
Console.ForegroundColor = ConsoleColor.DarkMagenta;
|
||||
Console.WriteLine("year : " + yearCouner);
|
||||
}
|
||||
|
||||
|
||||
if (yearCouner.Year == end.Year)
|
||||
{
|
||||
|
||||
|
||||
var endMonthCounter = new PersianDateTime(end.Year, end.Month, yearCouner.Day);
|
||||
|
||||
if (yearCouner.Day <= end.Day)
|
||||
{
|
||||
endMonthCounter = end;
|
||||
|
||||
}
|
||||
for (var monthCounter = yearCouner; monthCounter <= endMonthCounter; monthCounter = monthCounter.AddMonths(1))
|
||||
{
|
||||
if (monthCounter < end)
|
||||
{
|
||||
Console.ForegroundColor = ConsoleColor.Yellow;
|
||||
Console.WriteLine("month : " + monthCounter);
|
||||
months++;
|
||||
}
|
||||
|
||||
if (monthCounter.Month == end.Month)
|
||||
{
|
||||
var firstDayCounter = monthCounter.AddDays(1);
|
||||
if (yearCouner.Day > end.Day)
|
||||
{
|
||||
|
||||
firstDayCounter = firstDayCounter.AddMonths(-1);
|
||||
}
|
||||
for (var dayCounter = firstDayCounter; dayCounter <= end; dayCounter = dayCounter.AddDays(1))
|
||||
{
|
||||
if (dayCounter <= end)
|
||||
{
|
||||
days++;
|
||||
Console.ForegroundColor = ConsoleColor.Cyan;
|
||||
Console.WriteLine("day : " + dayCounter);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
months = months > 0 ? months - 1 : 0;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Console.ResetColor();
|
||||
Console.WriteLine($"old: [{years} year] ، [{months} month] ، [{days} day]");
|
||||
return (years,months,days);
|
||||
}
|
||||
|
||||
public static string ToFarsi(this DateTime? date)
|
||||
{
|
||||
|
||||
@@ -9,6 +9,7 @@ public class CreateTicket
|
||||
public string Title { get; set; }
|
||||
public string Description { get; set; }
|
||||
public long SenderId { get; set; }
|
||||
public long SubAccountId { get; set; }
|
||||
public string ContractingPartyName { get; set; }
|
||||
public string TicketType { get; set; }
|
||||
public List<long> UploadedMediaIds { get; set; }
|
||||
|
||||
@@ -68,7 +68,7 @@ public class TicketApplication : ITicketApplication
|
||||
var ticketNumber = (_ticketRepository.GetLastTicketNumber() + 1).ToString("D5");
|
||||
|
||||
var ticket = new Ticket(command.Title, command.Description, command.SenderId, command.ContractingPartyName,
|
||||
command.TicketType, command.WorkshopId, ticketNumber);
|
||||
command.TicketType, command.WorkshopId, ticketNumber, command.SubAccountId);
|
||||
_ticketRepository.Create(ticket);
|
||||
_ticketRepository.SaveChanges();
|
||||
|
||||
|
||||
@@ -112,82 +112,86 @@ public class TicketRepository : RepositoryBase<long, Ticket>, ITicketRepository
|
||||
return query.Skip(searchModel.PageIndex).Take(30).ToList();
|
||||
}
|
||||
|
||||
public List<TicketViewModel> GetTicketsForClients(TicketSearchModel searchModel)
|
||||
{
|
||||
public List<TicketViewModel> GetTicketsForClients(TicketSearchModel searchModel)
|
||||
{
|
||||
|
||||
var accountId = _authHelper.CurrentAccountId();
|
||||
var accountInfo = _authHelper.CurrentAccountInfo();
|
||||
|
||||
var workshopSlug = _authHelper.GetWorkshopSlug();
|
||||
var workshopId = _passwordHasher.SlugDecrypt(workshopSlug);
|
||||
IQueryable<Ticket> query;
|
||||
if (workshopId > 0)
|
||||
{
|
||||
query = _accountContext.Tickets.Where(x => x.SenderId == accountId && x.WorkshopId == workshopId);
|
||||
}
|
||||
else
|
||||
{
|
||||
query = _accountContext.Tickets.Where(x => x.SenderId == accountId);
|
||||
}
|
||||
if (!string.IsNullOrWhiteSpace(searchModel.ContractingPartyName))
|
||||
{
|
||||
query = query.Where(x => x.ContractingPartyName.Contains(searchModel.ContractingPartyName));
|
||||
}
|
||||
var workshopSlug = _authHelper.GetWorkshopSlug();
|
||||
var workshopId = _passwordHasher.SlugDecrypt(workshopSlug);
|
||||
IQueryable<Ticket> query;
|
||||
if (workshopId > 0)
|
||||
{
|
||||
query = _accountContext.Tickets.Where(x => x.SenderId == accountInfo.Id && x.WorkshopId == workshopId);
|
||||
}
|
||||
else
|
||||
{
|
||||
query = _accountContext.Tickets.Where(x => x.SenderId == accountInfo.Id);
|
||||
}
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(searchModel.Status))
|
||||
{
|
||||
query = query.Where(x => x.Status == searchModel.Status);
|
||||
}
|
||||
if (accountInfo.SubAccountId > 0)
|
||||
{
|
||||
query = query.Where(x => x.SubAccountSenderId == accountInfo.SubAccountId);
|
||||
}
|
||||
if (!string.IsNullOrWhiteSpace(searchModel.ContractingPartyName))
|
||||
{
|
||||
query = query.Where(x => x.ContractingPartyName.Contains(searchModel.ContractingPartyName));
|
||||
}
|
||||
|
||||
if (!(string.IsNullOrWhiteSpace(searchModel.StartDate) && string.IsNullOrWhiteSpace(searchModel.EndDate)))
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(searchModel.OneDay))
|
||||
{
|
||||
var startDate = searchModel.StartDate.ToGeorgianDateTime();
|
||||
var endDate = searchModel.EndDate.ToGeorgianDateTime();
|
||||
query = query.Where(x => startDate < x.CreationDate && endDate > x.CreationDate);
|
||||
}
|
||||
if (!string.IsNullOrWhiteSpace(searchModel.Status))
|
||||
{
|
||||
query = query.Where(x => x.Status == searchModel.Status);
|
||||
}
|
||||
|
||||
}
|
||||
if (!(string.IsNullOrWhiteSpace(searchModel.StartDate) && string.IsNullOrWhiteSpace(searchModel.EndDate)))
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(searchModel.OneDay))
|
||||
{
|
||||
var startDate = searchModel.StartDate.ToGeorgianDateTime();
|
||||
var endDate = searchModel.EndDate.ToGeorgianDateTime();
|
||||
query = query.Where(x => startDate < x.CreationDate && endDate > x.CreationDate);
|
||||
}
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(searchModel.GeneralSearch))
|
||||
{
|
||||
query = query.Where(x => x.Title.Contains(searchModel.GeneralSearch));
|
||||
}
|
||||
}
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(searchModel.Status))
|
||||
{
|
||||
query = query.Where(x => x.Status == searchModel.Status);
|
||||
}
|
||||
if (!string.IsNullOrWhiteSpace(searchModel.GeneralSearch))
|
||||
{
|
||||
query = query.Where(x => x.Title.Contains(searchModel.GeneralSearch));
|
||||
}
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(searchModel.OneDay))
|
||||
{
|
||||
var day = searchModel.OneDay.ToGeorgianDateTime();
|
||||
query = query.Where(x => x.CreationDate.Date == day.Date);
|
||||
}
|
||||
if (!string.IsNullOrWhiteSpace(searchModel.Status))
|
||||
{
|
||||
query = query.Where(x => x.Status == searchModel.Status);
|
||||
}
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(searchModel.OneDay))
|
||||
{
|
||||
var day = searchModel.OneDay.ToGeorgianDateTime();
|
||||
query = query.Where(x => x.CreationDate.Date == day.Date);
|
||||
}
|
||||
|
||||
|
||||
var res = query.OrderBy(x => x.Status.Trim() == "بسته شده").ThenByDescending(x => x.CreationDate).Select(x => new TicketViewModel()
|
||||
{
|
||||
Description = x.Description,
|
||||
SenderId = x.SenderId,
|
||||
ContractingPartyName = x.ContractingPartyName,
|
||||
Id = x.id,
|
||||
Title = x.Title,
|
||||
TicketType = x.TicketType,
|
||||
Status = x.Status,
|
||||
CreationDateTimeGr = x.CreationDate,
|
||||
CreationDateTime = x.CreationDate.ToFarsi(),
|
||||
TicketNumber = $"TKC_{x.TicketNumber}",
|
||||
WorkshopName = _workshopRepository.Get(x.WorkshopId).WorkshopFullName
|
||||
var res = query.OrderBy(x => x.Status.Trim() == "بسته شده").ThenByDescending(x => x.CreationDate).Select(x => new TicketViewModel()
|
||||
{
|
||||
Description = x.Description,
|
||||
SenderId = x.SenderId,
|
||||
ContractingPartyName = x.ContractingPartyName,
|
||||
Id = x.id,
|
||||
Title = x.Title,
|
||||
TicketType = x.TicketType,
|
||||
Status = x.Status,
|
||||
CreationDateTimeGr = x.CreationDate,
|
||||
CreationDateTime = x.CreationDate.ToFarsi(),
|
||||
TicketNumber = $"TKC_{x.TicketNumber}",
|
||||
WorkshopName = _workshopRepository.Get(x.WorkshopId).WorkshopFullName
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
return res.Skip(searchModel.PageIndex).Take(30).ToList();
|
||||
}
|
||||
return res.Skip(searchModel.PageIndex).Take(30).ToList();
|
||||
}
|
||||
|
||||
|
||||
public void CreateAdminResponse(AdminResponse command)
|
||||
public void CreateAdminResponse(AdminResponse command)
|
||||
{
|
||||
_accountContext.Add(command);
|
||||
}
|
||||
|
||||
@@ -942,11 +942,18 @@ public class YearlySalaryRepository : RepositoryBase<long, YearlySalary>, IYearl
|
||||
if (item.DateOfBirth < EndCantract)
|
||||
{
|
||||
Age = (EndCantract - item.DateOfBirth);
|
||||
var ageUp18 = (zeroTime + Age).Year - 1; var res = ageUp18;
|
||||
if (ageUp18 <= 18 && insurancHistoey >= 720)
|
||||
var ageUp18 = (zeroTime + Age).Year - 1;
|
||||
|
||||
var checkOld = Tools.GetOld(item.DateOfBirth, EndCantract);
|
||||
|
||||
if (checkOld.yearCount < 18 && insurancHistoey >= 720)
|
||||
{
|
||||
childeNumber += 1;
|
||||
}
|
||||
else if (checkOld.yearCount > 18 && checkOld.monthCount == 0)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -98,18 +98,20 @@ namespace ServiceHost.Areas.Client.Pages.Company.Ticket
|
||||
|
||||
public IActionResult OnPostSaveTicket(CreateTicket command)
|
||||
{
|
||||
var accountInfo = _authHelper.CurrentAccountInfo();
|
||||
command.SenderId = _authHelper.CurrentAccountId();
|
||||
command.ContractingPartyName = _authHelper.CurrentAccountInfo().Fullname;
|
||||
command.ContractingPartyName = accountInfo.Fullname;
|
||||
command.WorkshopId = _passwordHasher.SlugDecrypt(User.FindFirstValue("WorkshopSlug"));
|
||||
command.Description = command.Description?.Replace("\n", "<br>");
|
||||
|
||||
command.SubAccountId = accountInfo.SubAccountId;
|
||||
|
||||
var result = _ticketApplication.CreateTicket(command);
|
||||
return new JsonResult(new
|
||||
{
|
||||
isSuccedd = result.IsSuccedded,
|
||||
message = result.Message
|
||||
});
|
||||
|
||||
var result = _ticketApplication.CreateTicket(command);
|
||||
return new JsonResult(new
|
||||
{
|
||||
isSuccedd = result.IsSuccedded,
|
||||
message = result.Message
|
||||
});
|
||||
}
|
||||
|
||||
public IActionResult OnPostUploadFile(IFormFile media)
|
||||
|
||||
Reference in New Issue
Block a user