init
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="AutoMapper" Version="12.0.1" />
|
||||
<PackageReference Include="EPPlus" Version="6.0.8" />
|
||||
<PackageReference Include="Microsoft.AspNetCore" Version="2.2.0" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Authorization" Version="6.0.8" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="6.0.8" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.Core" Version="2.2.5" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\BlazorApp.DataLayer\BlazorApp.DataLayer.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Update="Resource\PanelManager.Designer.cs">
|
||||
<DesignTime>True</DesignTime>
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>PanelManager.resx</DependentUpon>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Update="Resource\PanelManager.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>PanelManager.Designer.cs</LastGenOutput>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -0,0 +1,50 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using BlazorApp.Core.DTOs;
|
||||
|
||||
namespace BlazorApp.Core.Convertors
|
||||
{
|
||||
public static class DateConvertor
|
||||
{
|
||||
public static string ToShamsi(this DateTime value)
|
||||
{
|
||||
PersianCalendar persian = new PersianCalendar();
|
||||
return persian.GetYear(value) + "/" + persian.GetMonth(value).ToString("00") + "/" + persian.GetDayOfMonth(value).ToString("00");
|
||||
}
|
||||
|
||||
public static string ToShamsi(this int value)
|
||||
{
|
||||
PersianCalendar persian = new PersianCalendar();
|
||||
DateTime date = new DateTime(value, 6, 1);
|
||||
return persian.GetYear(date).ToString();
|
||||
}
|
||||
|
||||
public static string ToYear(this DateTime value)
|
||||
{
|
||||
PersianCalendar persian = new PersianCalendar();
|
||||
return persian.GetYear(value).ToString();
|
||||
}
|
||||
|
||||
public static List<YearViewModel> GetYears()
|
||||
{
|
||||
PersianCalendar persian = new PersianCalendar();
|
||||
DateTime now = DateTime.Now;
|
||||
DateTime lastYear = now.AddYears(-1);
|
||||
DateTime year1 = now.AddYears(1);
|
||||
DateTime year2 = now.AddYears(2);
|
||||
|
||||
List<YearViewModel> Years = new List<YearViewModel>();
|
||||
|
||||
Years.Add(new YearViewModel() { YearNumber = int.Parse(persian.GetYear(lastYear).ToString()), PersianDate = persian.GetYear(lastYear).ToString() });
|
||||
Years.Add(new YearViewModel() { YearNumber = int.Parse(persian.GetYear(now).ToString()), PersianDate = persian.GetYear(now).ToString() });
|
||||
Years.Add(new YearViewModel() { YearNumber = int.Parse(persian.GetYear(year1).ToString()), PersianDate = persian.GetYear(year1).ToString() });
|
||||
Years.Add(new YearViewModel() { YearNumber = int.Parse(persian.GetYear(year2).ToString()), PersianDate = persian.GetYear(year2).ToString() });
|
||||
|
||||
return Years;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BlazorApp.Core.DTOs
|
||||
{
|
||||
public class LoginViewModel
|
||||
{
|
||||
[Display(Name = "نام کاربری")]
|
||||
[Required(ErrorMessage = "لطفا {0} را وارد کنید")]
|
||||
[MaxLength(250)]
|
||||
public string UserName { get; set; }
|
||||
|
||||
[Display(Name = "گذرواژه")]
|
||||
[Required(ErrorMessage = "لطفا {0} را وارد کنید")]
|
||||
[MaxLength(250)]
|
||||
public string Password { get; set; }
|
||||
|
||||
[Display(Name = "مرا بخاطر بسپار")]
|
||||
public bool RememberMe { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BlazorApp.Core.DTOs
|
||||
{
|
||||
public class ReportMonthViewModel
|
||||
{
|
||||
public int MonthId { get; set; }
|
||||
public int PlanId { get; set; }
|
||||
public string MonthTitle { get; set; }
|
||||
public int RequestNumber { get; set; }
|
||||
}
|
||||
|
||||
public class ReqCollegeForAdminViewModel
|
||||
{
|
||||
public int RequestId { get; set; }
|
||||
public int ScheduleId { get; set; }
|
||||
public int CollegeId { get; set; }
|
||||
public int PlanId { get; set; }
|
||||
|
||||
public string ScheduleTitle { get; set; }
|
||||
|
||||
public string OU_Title { get; set; }
|
||||
|
||||
public float AllocationAmount { get; set; }
|
||||
|
||||
public float RequestAmount { get; set; }
|
||||
|
||||
public float OU_Amount { get; set; }
|
||||
|
||||
public float ManagerAmount { get; set; }
|
||||
|
||||
}
|
||||
|
||||
public class ReqUnitForAdminViewModel
|
||||
{
|
||||
public int RequestId { get; set; }
|
||||
public int ScheduleId { get; set; }
|
||||
public int PlanId { get; set; }
|
||||
|
||||
public string ScheduleTitle { get; set; }
|
||||
|
||||
public float AllocationAmount { get; set; }
|
||||
|
||||
public float RequestAmount { get; set; }
|
||||
|
||||
public float ManagerAmount { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
using AutoMapper;
|
||||
using BlazorApp.DataLayer.Entities.TalentSearchs;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BlazorApp.Core.DTOs
|
||||
{
|
||||
public class AutoMapping:Profile
|
||||
{
|
||||
public AutoMapping()
|
||||
{
|
||||
CreateMap<Personnel, CreatePersonnelViewModel>();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,228 @@
|
||||
using BlazorApp.DataLayer.Entities;
|
||||
using BlazorApp.DataLayer.Entities.Colleges.Schedule;
|
||||
using BlazorApp.DataLayer.Entities.OrganizationalUnits;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BlazorApp.Core.DTOs
|
||||
{
|
||||
public class CreateProgramCollegeViewModel
|
||||
{
|
||||
public int CollegeId { get; set; }
|
||||
public int ProgramYear { get; set; }
|
||||
}
|
||||
|
||||
public class ProgramItemViewModel
|
||||
{
|
||||
public int ItemId { get; set; }
|
||||
public int PC_Id { get; set; }
|
||||
public string OU_Title { get; set; }
|
||||
public string ItemTitle { get; set; }
|
||||
public int TotalAmount { get; set; }
|
||||
}
|
||||
|
||||
|
||||
public class CreateProgramCollegeItemViewModel
|
||||
{
|
||||
|
||||
#region Items
|
||||
public int ItemId { get; set; }
|
||||
|
||||
//program college
|
||||
public int PC_Id { get; set; }
|
||||
|
||||
|
||||
//واحد سازمانی
|
||||
[Display(Name = "واحد سازمانی")]
|
||||
public int OU_Id { get; set; }
|
||||
|
||||
//نوع برنامه(تکلیفی/برنامه ای)
|
||||
[Display(Name = "نوع برنامه")]
|
||||
public int AppTypeId { get; set; }
|
||||
|
||||
//سطح اجرا : ستاد/صف
|
||||
[Display(Name = "سطح اجرا")]
|
||||
public int LevelId { get; set; }
|
||||
|
||||
|
||||
//برنامه عملیاتی
|
||||
[Display(Name = "عنوان برنامه عملیاتی")]
|
||||
[MaxLength(500)]
|
||||
public string ItemTitle { get; set; }
|
||||
|
||||
//هدف
|
||||
[Display(Name = "هدف")]
|
||||
[MaxLength(50)]
|
||||
public string Target { get; set; }
|
||||
|
||||
//راهبرد
|
||||
[Display(Name = "راهبرد")]
|
||||
[MaxLength(50)]
|
||||
public string Strategy { get; set; }
|
||||
|
||||
//شناسه هزینه ای
|
||||
[Display(Name = "شناسه هزینه")]
|
||||
[MaxLength(50)]
|
||||
public string CostIndex { get; set; }
|
||||
|
||||
//شناسه درآمدی مرتبط
|
||||
[Display(Name = "شناسه درآمدی مرتبط")]
|
||||
[MaxLength(50)]
|
||||
public string RevenueIndex { get; set; }
|
||||
|
||||
//اولویت
|
||||
[Display(Name = "اولویت")]
|
||||
public int? Priority { get; set; }
|
||||
|
||||
|
||||
//ضریب اهمیت
|
||||
[Display(Name = "ضریب اهمیت")]
|
||||
public int? Importance { get; set; }
|
||||
|
||||
|
||||
//شاخص سنجش
|
||||
[Display(Name = "شاخص سنجش")]
|
||||
[MaxLength(50)]
|
||||
public string TestIndex { get; set; }
|
||||
|
||||
|
||||
//کیمت
|
||||
[Display(Name = "کمیت")]
|
||||
[MaxLength(50)]
|
||||
public string Quantity { get; set; }
|
||||
#endregion
|
||||
|
||||
#region Months
|
||||
[Display(Name = "فروردین")]
|
||||
public int? Farvardin { get; set; }
|
||||
|
||||
[Display(Name = "اردیبهشت")]
|
||||
public int? Ordibehesht { get; set; }
|
||||
|
||||
[Display(Name = "خرداد")]
|
||||
public int? Khordad { get; set; }
|
||||
|
||||
[Display(Name = "تیر")]
|
||||
public int? Tir { get; set; }
|
||||
|
||||
[Display(Name = "مرداد")]
|
||||
public int? Mordad { get; set; }
|
||||
|
||||
[Display(Name = "شهریور")]
|
||||
public int? Shahrivar { get; set; }
|
||||
|
||||
[Display(Name = "مهر")]
|
||||
public int? Mehr { get; set; }
|
||||
|
||||
[Display(Name = "آبان")]
|
||||
public int? Aban { get; set; }
|
||||
|
||||
[Display(Name = "آذر")]
|
||||
public int? Azar { get; set; }
|
||||
|
||||
[Display(Name = "دی")]
|
||||
public int? Dey { get; set; }
|
||||
|
||||
[Display(Name = "بهمن")]
|
||||
public int? Bahman { get; set; }
|
||||
|
||||
[Display(Name = "اسفند")]
|
||||
public int? Esfand { get; set; }
|
||||
#endregion
|
||||
|
||||
}
|
||||
|
||||
|
||||
#region Schedule
|
||||
public class ScheduleOfCollegeViewModel
|
||||
{
|
||||
public int ScheduleId { get; set; }
|
||||
public string OU_Title { get; set; }
|
||||
public string ScheduleTitile { get; set; }
|
||||
public float TotalAmount { get; set; }
|
||||
public float PaymentAmount { get; set; }
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region NewSchedule
|
||||
public class ScheduleOfCollegeByFilterViewModel:InfoOfScheduleViewModel
|
||||
{
|
||||
public int ScheduleId { get; set; }
|
||||
|
||||
[Display(Name = "سال")]
|
||||
public YearOfPlan Plan { get; set; }
|
||||
|
||||
[Display(Name = "ماه")]
|
||||
public Month Month { get; set; }
|
||||
|
||||
[Display(Name = "عنوان برنامه")]
|
||||
public ScheduleText ScheduleTitle { get; set; }
|
||||
|
||||
public RequestFromCollege Request { get; set; }
|
||||
|
||||
//public float AllocationAmount { get; set; }
|
||||
|
||||
//public float RequestAmount { get; set; }
|
||||
|
||||
//public float OuAmount { get; set; }
|
||||
|
||||
//public float ManagerAmount { get; set; }
|
||||
|
||||
//public float PaymentAmount { get; set; }
|
||||
|
||||
#region Info
|
||||
|
||||
////هدف
|
||||
//[Display(Name = "هدف")]
|
||||
//[MaxLength(50)]
|
||||
//public string Target { get; set; }
|
||||
|
||||
////راهبرد
|
||||
//[Display(Name = "راهبرد")]
|
||||
//public string Strategy { get; set; }
|
||||
|
||||
////شناسه هزینه ای
|
||||
//[Display(Name = "شناسه هزینه")]
|
||||
//public string CostIndex { get; set; }
|
||||
|
||||
////نوع برنامه(تکلیفی/برنامه ای)
|
||||
//[Display(Name = "نوع برنامه")]
|
||||
//public int AppTypeId { get; set; }
|
||||
|
||||
////سطح اجرا : ستاد/صف
|
||||
//[Display(Name = "سطح اجرا")]
|
||||
//public int LevelId { get; set; }
|
||||
|
||||
////اولویت
|
||||
//[Display(Name = "اولویت")]
|
||||
//public int? Priority { get; set; }
|
||||
|
||||
////ضریب اهمیت
|
||||
//[Display(Name = "ضریب اهمیت")]
|
||||
//public int? Importance { get; set; }
|
||||
|
||||
////کیمت
|
||||
//[Display(Name = "کمیت")]
|
||||
//public string Quantity { get; set; }
|
||||
|
||||
////شناسه درآمدی مرتبط
|
||||
//[Display(Name = "شناسه درآمدی مرتبط")]
|
||||
//public string RevenueIndex { get; set; }
|
||||
|
||||
////شاخص سنجش
|
||||
//[Display(Name = "شاخص سنجش")]
|
||||
//public string TestIndex { get; set; }
|
||||
|
||||
|
||||
//[Display(Name = "براورد هزینه")]
|
||||
//public float TotalCost { get; set; }
|
||||
|
||||
#endregion
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
using BlazorApp.DataLayer.Entities.Colleges.Schedule;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BlazorApp.Core.DTOs
|
||||
{
|
||||
public class ConfirmRequestForOuViewModel
|
||||
{
|
||||
public int ScheduleId { get; set; }
|
||||
|
||||
public int MonthId { get; set; }
|
||||
|
||||
public string ScheduleTitle { get; set; }
|
||||
|
||||
public RequestFromCollege Request { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
using BlazorApp.DataLayer.Entities.Colleges.Schedule;
|
||||
using BlazorApp.DataLayer.Entities.OrganizationalUnits;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace BlazorApp.Core.DTOs
|
||||
{
|
||||
public class ConfirmUnitRequestForAdminViewModel
|
||||
{
|
||||
[Display(Name = "سال")]
|
||||
public string YearNumber { get; set; }
|
||||
|
||||
[Display(Name = "عنوان برنامه")]
|
||||
public string ScheduleTitle { get; set; }
|
||||
|
||||
[Display(Name = "واحد سازمانی")]
|
||||
public string UnitTitle { get; set; }
|
||||
|
||||
[Display(Name = "ماه")]
|
||||
public string MonthTitle { get; set; }
|
||||
|
||||
public RequestFromUnit Request { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
using BlazorApp.DataLayer.Entities;
|
||||
using BlazorApp.DataLayer.Entities.Colleges;
|
||||
using BlazorApp.DataLayer.Entities.Colleges.Schedule;
|
||||
using BlazorApp.DataLayer.Entities.OrganizationalUnits;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BlazorApp.Core.DTOs
|
||||
{
|
||||
public class ConfrimCollegeRequestForAdminViewModel
|
||||
{
|
||||
[Display(Name = "سال")]
|
||||
public string YearNumber { get; set; }
|
||||
|
||||
[Display(Name = "دانشکده")]
|
||||
public string CollegeTitle { get; set; }
|
||||
|
||||
[Display(Name = "عنوان برنامه")]
|
||||
public string ScheduleTitle { get; set; }
|
||||
|
||||
[Display(Name = "واحد سازمانی")]
|
||||
public string UnitTitle { get; set; }
|
||||
|
||||
[Display(Name = "ماه")]
|
||||
public string MonthTitle { get; set; }
|
||||
|
||||
public RequestFromCollege Request { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BlazorApp.Core.DTOs
|
||||
{
|
||||
public class YearViewModel
|
||||
{
|
||||
public int YearNumber { get; set; }
|
||||
|
||||
[Display(Name = "سال")]
|
||||
public string PersianDate { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BlazorApp.Core.DTOs
|
||||
{
|
||||
public class FilterByOuViewModel:FilterViewModel
|
||||
{
|
||||
|
||||
public int OuId { get; set; }
|
||||
}
|
||||
|
||||
public class FilterViewModel
|
||||
{
|
||||
public int PlanId { get; set; }
|
||||
|
||||
public int MonthId { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace BlazorApp.Core.DTOs
|
||||
{
|
||||
public class InfoOfScheduleViewModel
|
||||
{
|
||||
//هدف
|
||||
[Display(Name = "هدف")]
|
||||
[MaxLength(50)]
|
||||
public string Target { get; set; }
|
||||
|
||||
//راهبرد
|
||||
[Display(Name = "راهبرد")]
|
||||
public string Strategy { get; set; }
|
||||
|
||||
//شناسه هزینه ای
|
||||
[Display(Name = "شناسه هزینه")]
|
||||
public string CostIndex { get; set; }
|
||||
|
||||
//نوع برنامه(تکلیفی/برنامه ای)
|
||||
[Display(Name = "نوع برنامه")]
|
||||
public int AppTypeId { get; set; }
|
||||
|
||||
//سطح اجرا : ستاد/صف
|
||||
[Display(Name = "سطح اجرا")]
|
||||
public int LevelId { get; set; }
|
||||
|
||||
//اولویت
|
||||
[Display(Name = "اولویت")]
|
||||
public int? Priority { get; set; }
|
||||
|
||||
//ضریب اهمیت
|
||||
[Display(Name = "ضریب اهمیت")]
|
||||
public int? Importance { get; set; }
|
||||
|
||||
//کیمت
|
||||
[Display(Name = "کمیت")]
|
||||
public string Quantity { get; set; }
|
||||
|
||||
//شناسه درآمدی مرتبط
|
||||
[Display(Name = "شناسه درآمدی مرتبط")]
|
||||
public string RevenueIndex { get; set; }
|
||||
|
||||
//شاخص سنجش
|
||||
[Display(Name = "شاخص سنجش")]
|
||||
public string TestIndex { get; set; }
|
||||
|
||||
|
||||
[Display(Name = "براورد هزینه")]
|
||||
public float TotalCost { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
using BlazorApp.DataLayer.Entities.Colleges;
|
||||
using BlazorApp.DataLayer.Entities.TalentSearchs;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml.Linq;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace BlazorApp.Core.DTOs
|
||||
{
|
||||
public class CreatePersonnelViewModel
|
||||
{
|
||||
public int PersonnelId { get; set; }
|
||||
|
||||
[Required(ErrorMessage = "لطفا {0} را وارد کنید")]
|
||||
public int CollegeId { get; set; }
|
||||
|
||||
[Display(Name = "کد پرسنلی")]
|
||||
[Required(ErrorMessage = "لطفا {0} را وارد کنید")]
|
||||
public string? PersonnelCode { get; set; }
|
||||
|
||||
[Display(Name = "کد ملی")]
|
||||
[MaxLength(10)]
|
||||
[MinLength(10)]
|
||||
[Required(ErrorMessage = "لطفا {0} را وارد کنید")]
|
||||
public string? NationalCode { get; set; }
|
||||
|
||||
[Display(Name = "نام")]
|
||||
[Required(ErrorMessage = "لطفا {0} را وارد کنید")]
|
||||
[MaxLength(50)]
|
||||
public string? PersonnelName { get; set; }
|
||||
|
||||
[Display(Name = "نام خانوادگی")]
|
||||
[Required(ErrorMessage = "لطفا {0} را وارد کنید")]
|
||||
[MaxLength(50)]
|
||||
public string? PersonnelFamily { get; set; }
|
||||
|
||||
[Display(Name = "نام کاربری")]
|
||||
[Required(ErrorMessage = "لطفا {0} را وارد کنید")]
|
||||
[MaxLength(50)]
|
||||
public string? UserName { get; set; }
|
||||
}
|
||||
|
||||
public class UpdatePasswordForPersonnelFromAdminViewModel
|
||||
{
|
||||
public int PersonnelId { get; set; }
|
||||
|
||||
[Display(Name = "گذرواژه جدید")]
|
||||
[Required(ErrorMessage = "لطفا {0} را وارد کنید")]
|
||||
public string? NewPassword { get; set; }
|
||||
|
||||
[Display(Name = "تکرار گذرواژه جدید")]
|
||||
[Required(ErrorMessage = "لطفا {0} را وارد کنید")]
|
||||
[Compare(nameof(NewPassword))]
|
||||
public string? ReNewPassword { get; set; }
|
||||
}
|
||||
|
||||
public class UpdatePasswordForPersonnelFromUserViewModel
|
||||
{
|
||||
public int PersonnelId { get; set; }
|
||||
|
||||
[Display(Name = "گذرواژه فعلی")]
|
||||
[Required(ErrorMessage = "لطفا {0} را وارد کنید")]
|
||||
public string? CurrentPassword { get; set; }
|
||||
|
||||
|
||||
[Display(Name = "گذرواژه جدید")]
|
||||
[Required(ErrorMessage = "لطفا {0} را وارد کنید")]
|
||||
public string? NewPassword { get; set; }
|
||||
|
||||
[Display(Name = "تکرار گذرواژه جدید")]
|
||||
[Required(ErrorMessage = "لطفا {0} را وارد کنید")]
|
||||
[Compare(nameof(NewPassword))]
|
||||
public string? ReNewPassword { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
using BlazorApp.DataLayer.Entities.Colleges;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BlazorApp.Core.DTOs
|
||||
{
|
||||
public class ReportUnitViewModel
|
||||
{
|
||||
|
||||
public int OuId { get; set; }
|
||||
|
||||
public string UnitTitle { get; set; }
|
||||
|
||||
public float AllocationAmount { get; set; }
|
||||
|
||||
public float RequestAmount { get; set; }
|
||||
|
||||
public float Ou_Amount { get; set; }
|
||||
|
||||
public float ManagerAmount { get; set; }
|
||||
|
||||
public float PaymentAmount { get; set; }
|
||||
}
|
||||
|
||||
public class ReportCollegeViewModel
|
||||
{
|
||||
public College College { get; set; }
|
||||
|
||||
public float AllocationAmount { get; set; }
|
||||
|
||||
public float RequestAmount { get; set; }
|
||||
|
||||
public float OuAmount { get; set; }
|
||||
|
||||
public float ManagerAmount { get; set; }
|
||||
|
||||
public float PaymentAmount { get; set; }
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
using BlazorApp.DataLayer.Entities;
|
||||
using BlazorApp.DataLayer.Entities.OrganizationalUnits;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BlazorApp.Core.DTOs
|
||||
{
|
||||
public class ScheduleOfOUViewModel
|
||||
{
|
||||
public int ScheduleId { get; set; }
|
||||
public string ScheduleTitile { get; set; }
|
||||
public float TotalAmount { get; set; }
|
||||
public float PaymentAmount { get; set; }
|
||||
}
|
||||
|
||||
public class RequestCollegeViewModel
|
||||
{
|
||||
public int CollegeId { get; set; }
|
||||
|
||||
[Display(Name = "دانشکده")]
|
||||
public string CollegeTitle { get; set; }
|
||||
|
||||
public int RequestNumber { get; set; }
|
||||
}
|
||||
|
||||
public class ScheduleOfOuByFilterViewModel:InfoOfScheduleViewModel
|
||||
{
|
||||
public int ScheduleId { get; set; }
|
||||
|
||||
[Display(Name = "سال")]
|
||||
public YearOfPlan Plan { get; set; }
|
||||
|
||||
[Display(Name = "ماه")]
|
||||
public Month Month { get; set; }
|
||||
|
||||
[Display(Name = "عنوان برنامه")]
|
||||
public ScheduleText ScheduleTitle { get; set; }
|
||||
|
||||
public RequestFromUnit Request { get; set; }
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,332 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BlazorApp.Core.DTOs
|
||||
{
|
||||
public class UsersForShowViewModel
|
||||
{
|
||||
public int UserId { get; set; }
|
||||
public string FullName { get; set; }
|
||||
public string UserName { get; set; }
|
||||
public string ImageName { get; set; }
|
||||
}
|
||||
|
||||
public class ProfileViewModel
|
||||
{
|
||||
public int UserId { get; set; }
|
||||
|
||||
#region Personal Profile
|
||||
|
||||
[Display(Name = "نام کاربری")]
|
||||
[Required(ErrorMessage = "لطفا {0} را وارد کنید")]
|
||||
public string UserName { get; set; }
|
||||
|
||||
[DataType(DataType.Password)]
|
||||
[Display(Name = "رمز عبور")]
|
||||
[Required(ErrorMessage = "لطفا {0} را وارد کنید")]
|
||||
public string Password { get; set; }
|
||||
|
||||
public string ImageName { get; set; }
|
||||
|
||||
[Display(Name = "نام")]
|
||||
[Required(ErrorMessage = "لطفا {0} را وارد کنید")]
|
||||
public string Name { get; set; }
|
||||
|
||||
[Display(Name = "نام خانوادگی")]
|
||||
[Required(ErrorMessage = "لطفا {0} را وارد کنید")]
|
||||
public string Family { get; set; }
|
||||
|
||||
public string Role { get; set; }
|
||||
|
||||
[Display(Name = "کد ملی")]
|
||||
[MaxLength(250)]
|
||||
public string NationalCode { get; set; }
|
||||
|
||||
[Display(Name = "تایخ تولد")]
|
||||
[DisplayFormat(DataFormatString = "{0:yyyy/MM/dd}", ApplyFormatInEditMode = true)]
|
||||
public DateTime DateOfBirth { get; set; }
|
||||
|
||||
[Display(Name = "محل خدمت")]
|
||||
public int ServiceLocation { get; set; }
|
||||
|
||||
[Display(Name = "وضعیت تاهل")]
|
||||
public int Marriage { get; set; }
|
||||
|
||||
[Display(Name = "تعداد فرزند")]
|
||||
public int ChildrenCount { get; set; }
|
||||
|
||||
|
||||
[Display(Name = "مدرک تحصیلی (مطابق حکم کارگزینی)")]
|
||||
public int Education { get; set; }
|
||||
|
||||
[Display(Name = "تاریخ استخدام (در دانشگاه)")]
|
||||
public DateTime DateRecruitment { get; set; }
|
||||
|
||||
[Display(Name = "تعداد پایه (مطابق حکم کارگزینی)")]
|
||||
public int BaseNumber { get; set; }
|
||||
#endregion
|
||||
|
||||
#region Contact
|
||||
|
||||
[DataType(DataType.EmailAddress)]
|
||||
[Display(Name = "ایمیل")]
|
||||
public string Email { get; set; }
|
||||
|
||||
[Display(Name = "شماره تلفن همراه")]
|
||||
[MaxLength(250)]
|
||||
public string MobileNumber { get; set; }
|
||||
|
||||
[Display(Name = "تلفن ثابت (محل کار) مستقیم")]
|
||||
[MaxLength(250)]
|
||||
public string JubDirectNumber { get; set; }
|
||||
|
||||
|
||||
[MaxLength(250)]
|
||||
[Display(Name = "دانشکده")]
|
||||
public string CollegeNumber { get; set; }
|
||||
|
||||
[MaxLength(250)]
|
||||
[Display(Name = "داخلی")]
|
||||
public string InternalNumber { get; set; }
|
||||
|
||||
[Display(Name = "استان")]
|
||||
public int Province { get; set; }
|
||||
|
||||
[Display(Name = "شهر")]
|
||||
public int City { get; set; }
|
||||
|
||||
[MaxLength(800)]
|
||||
[Display(Name = "آدرس")]
|
||||
public string Address { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public class UserForAdminViewModel
|
||||
{
|
||||
public int UserId { get; set; }
|
||||
|
||||
#region Personal Profile
|
||||
|
||||
[Display(Name = "نام کاربری")]
|
||||
[Required(ErrorMessage = "لطفا {0} را وارد کنید")]
|
||||
public string UserName { get; set; }
|
||||
|
||||
[DataType(DataType.Password)]
|
||||
[Display(Name = "رمز عبور")]
|
||||
public string Password { get; set; }
|
||||
|
||||
public string ImageName { get; set; }
|
||||
|
||||
[Display(Name = "نام")]
|
||||
[Required(ErrorMessage = "لطفا {0} را وارد کنید")]
|
||||
public string Name { get; set; }
|
||||
|
||||
[Display(Name = "نام خانوادگی")]
|
||||
[Required(ErrorMessage = "لطفا {0} را وارد کنید")]
|
||||
public string Family { get; set; }
|
||||
|
||||
public string Role { get; set; }
|
||||
|
||||
[Display(Name = "کد ملی")]
|
||||
[MaxLength(250)]
|
||||
public string NationalCode { get; set; }
|
||||
|
||||
[Display(Name = "تایخ تولد")]
|
||||
[DisplayFormat(DataFormatString = "{0:yyyy/MM/dd}", ApplyFormatInEditMode = true)]
|
||||
public DateTime DateOfBirth { get; set; }
|
||||
|
||||
[Display(Name = "محل خدمت")]
|
||||
public int ServiceLocation { get; set; }
|
||||
|
||||
[Display(Name = "وضعیت تاهل")]
|
||||
public int Marriage { get; set; }
|
||||
|
||||
[Display(Name = "تعداد فرزند")]
|
||||
public int ChildrenCount { get; set; }
|
||||
|
||||
|
||||
[Display(Name = "مدرک تحصیلی (مطابق حکم کارگزینی)")]
|
||||
public int Education { get; set; }
|
||||
|
||||
[Display(Name = "تاریخ استخدام (در دانشگاه)")]
|
||||
public DateTime DateRecruitment { get; set; }
|
||||
|
||||
[Display(Name = "تعداد پایه (مطابق حکم کارگزینی)")]
|
||||
public int BaseNumber { get; set; }
|
||||
#endregion
|
||||
|
||||
#region Contact
|
||||
|
||||
[DataType(DataType.EmailAddress)]
|
||||
[Display(Name = "ایمیل")]
|
||||
public string Email { get; set; }
|
||||
|
||||
[Display(Name = "شماره تلفن همراه")]
|
||||
[MaxLength(250)]
|
||||
public string MobileNumber { get; set; }
|
||||
|
||||
[Display(Name = "تلفن ثابت (محل کار) مستقیم")]
|
||||
[MaxLength(250)]
|
||||
public string JubDirectNumber { get; set; }
|
||||
|
||||
|
||||
[MaxLength(250)]
|
||||
[Display(Name = "دانشکده")]
|
||||
public string CollegeNumber { get; set; }
|
||||
|
||||
[MaxLength(250)]
|
||||
[Display(Name = "داخلی")]
|
||||
public string InternalNumber { get; set; }
|
||||
|
||||
[Display(Name = "استان")]
|
||||
public int Province { get; set; }
|
||||
|
||||
[Display(Name = "شهر")]
|
||||
public int City { get; set; }
|
||||
|
||||
[MaxLength(800)]
|
||||
[Display(Name = "آدرس")]
|
||||
public string Address { get; set; }
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
public class UpdatePasswordViewModel
|
||||
{
|
||||
public int UserId { get; set; }
|
||||
|
||||
[Display(Name = "رمز عبور فعلی")]
|
||||
[Required(ErrorMessage = "لطفا {0} را وارد کنید")]
|
||||
[DataType(DataType.Password)]
|
||||
public string OldPassword { get; set; }
|
||||
|
||||
[Display(Name = "رمز عبور جدید")]
|
||||
[Required(ErrorMessage = "لطفا {0} را وارد کنید")]
|
||||
[DataType(DataType.Password)]
|
||||
public string Password { get; set; }
|
||||
|
||||
[Display(Name = "تکرار رمز عبور جدید")]
|
||||
[Required(ErrorMessage = "لطفا {0} را وارد کنید")]
|
||||
[DataType(DataType.Password)]
|
||||
[Compare("Password",ErrorMessage = "کلمات عبور با یکدیگر مغایرت دارند")]
|
||||
public string RePassword { get; set; }
|
||||
}
|
||||
|
||||
public class UpdateUserNameViewModel
|
||||
{
|
||||
public int UserId { get; set; }
|
||||
|
||||
[Display(Name = "نام کاربری فعلی")]
|
||||
public string UserName { get; set; }
|
||||
|
||||
[Display(Name = "نام کاربری جدید")]
|
||||
[Required(ErrorMessage = "لطفا {0} را وارد کنید")]
|
||||
public string NewUserName { get; set; }
|
||||
}
|
||||
|
||||
public class UpdateUsernameViewModel
|
||||
{
|
||||
public int UserId { get; set; }
|
||||
|
||||
[Display(Name = "رمز عبور")]
|
||||
[Required(ErrorMessage = "لطفا {0} را وارد کنید")]
|
||||
[DataType(DataType.Password)]
|
||||
public string Password { get; set; }
|
||||
|
||||
[Display(Name = "نام کاربری جدید")]
|
||||
[Required(ErrorMessage = "لطفا {0} را وارد کنید")]
|
||||
public string UserName { get; set; }
|
||||
}
|
||||
|
||||
public class CreateUser
|
||||
{
|
||||
public int CollegeOrOU_Id { get; set; }
|
||||
|
||||
[Display(Name = "نام")]
|
||||
[Required(ErrorMessage = "لطفا {0} را وارد کنید")]
|
||||
[MaxLength(250)]
|
||||
public string Name { get; set; }
|
||||
|
||||
[Display(Name = "نام خانوادگی")]
|
||||
[MaxLength(250)]
|
||||
public string Family { get; set; }
|
||||
|
||||
[Display(Name = "نام کاربری")]
|
||||
[Required(ErrorMessage = "لطفا {0} را وارد کنید")]
|
||||
[MaxLength(250)]
|
||||
public string UserName { get; set; }
|
||||
|
||||
[Display(Name = "ایمیل")]
|
||||
[DataType(DataType.EmailAddress)]
|
||||
[MaxLength(250)]
|
||||
public string Email { get; set; }
|
||||
|
||||
[Display(Name = "رمز عبور")]
|
||||
[DataType(DataType.Password)]
|
||||
[Required(ErrorMessage = "لطفا {0} را وارد کنید")]
|
||||
[MaxLength(250)]
|
||||
public string Password { get; set; }
|
||||
|
||||
[Display(Name = "تکرار رمز عبور")]
|
||||
[DataType(DataType.Password)]
|
||||
[Required(ErrorMessage = "لطفا {0} را وارد کنید")]
|
||||
[MaxLength(250)]
|
||||
[Compare("Password",ErrorMessage ="رمز های عبور با یکدیگر مغایرت دارند")]
|
||||
public string RePassword { get; set; }
|
||||
}
|
||||
|
||||
public class UpdateUser
|
||||
{
|
||||
public int UserId { get; set; }
|
||||
public int CollegeOrOU_Id { get; set; }
|
||||
|
||||
[Display(Name = "نام")]
|
||||
[Required(ErrorMessage = "لطفا {0} را وارد کنید")]
|
||||
[MaxLength(250)]
|
||||
public string Name { get; set; }
|
||||
|
||||
[Display(Name = "نام خانوادگی")]
|
||||
[MaxLength(250)]
|
||||
public string Family { get; set; }
|
||||
|
||||
[Display(Name = "نام کاربری")]
|
||||
[Required(ErrorMessage = "لطفا {0} را وارد کنید")]
|
||||
[MaxLength(250)]
|
||||
public string UserName { get; set; }
|
||||
|
||||
[Display(Name = "ایمیل")]
|
||||
[DataType(DataType.EmailAddress)]
|
||||
[MaxLength(250)]
|
||||
public string Email { get; set; }
|
||||
|
||||
|
||||
//[Display(Name = "رمز عبور")]
|
||||
//[Required(ErrorMessage = "لطفا {0} را وارد کنید")]
|
||||
//[DataType(DataType.Password)]
|
||||
//[MaxLength(250)]
|
||||
//public string OldPassword { get; set; }
|
||||
|
||||
[Display(Name = "رمز عبور جدید")]
|
||||
[DataType(DataType.Password)]
|
||||
[MaxLength(250)]
|
||||
public string Password { get; set; }
|
||||
|
||||
[Display(Name = "تکرار رمز عبور جدید")]
|
||||
[DataType(DataType.Password)]
|
||||
[MaxLength(250)]
|
||||
[Compare("Password", ErrorMessage = "رمز های عبور با یکدیگر مغایرت دارند")]
|
||||
public string RePassword { get; set; }
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
using System;
|
||||
|
||||
namespace BlazorApp.Core
|
||||
{
|
||||
public class NameGenerator
|
||||
{
|
||||
public static string GenerateUniqCode()
|
||||
{
|
||||
return Guid.NewGuid().ToString().Replace("-", "");
|
||||
}
|
||||
}
|
||||
}
|
||||
+126
@@ -0,0 +1,126 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.42000
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace BlazorApp.Core {
|
||||
using System;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// A strongly-typed resource class, for looking up localized strings, etc.
|
||||
/// </summary>
|
||||
// This class was auto-generated by the StronglyTypedResourceBuilder
|
||||
// class via a tool like ResGen or Visual Studio.
|
||||
// To add or remove a member, edit your .ResX file then rerun ResGen
|
||||
// with the /str option, or rebuild your VS project.
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
public class PanelManager {
|
||||
|
||||
private static global::System.Resources.ResourceManager resourceMan;
|
||||
|
||||
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||
|
||||
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||
public PanelManager() {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the cached ResourceManager instance used by this class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
public static global::System.Resources.ResourceManager ResourceManager {
|
||||
get {
|
||||
if (object.ReferenceEquals(resourceMan, null)) {
|
||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("BlazorApp.Core.Resource.PanelManager", typeof(PanelManager).Assembly);
|
||||
resourceMan = temp;
|
||||
}
|
||||
return resourceMan;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Overrides the current thread's CurrentUICulture property for all
|
||||
/// resource lookups using this strongly typed resource class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Globalization.CultureInfo Culture {
|
||||
get {
|
||||
return resourceCulture;
|
||||
}
|
||||
set {
|
||||
resourceCulture = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to شناسه تکراری میباشد.
|
||||
/// </summary>
|
||||
internal static string ConflictIdMission {
|
||||
get {
|
||||
return ResourceManager.GetString("ConflictIdMission", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to نام کاربری تکراری میباشد.
|
||||
/// </summary>
|
||||
internal static string ConflictUserName {
|
||||
get {
|
||||
return ResourceManager.GetString("ConflictUserName", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to دیتا کامل نمیباشد لطفا {0} را پر کیند.
|
||||
/// </summary>
|
||||
internal static string DataNotComplete {
|
||||
get {
|
||||
return ResourceManager.GetString("DataNotComplete", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to عملیات با خطا مواجه شد.
|
||||
/// </summary>
|
||||
internal static string Error {
|
||||
get {
|
||||
return ResourceManager.GetString("Error", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to فرمت نامعتبر میباشد.
|
||||
/// </summary>
|
||||
internal static string InvalidFormat {
|
||||
get {
|
||||
return ResourceManager.GetString("InvalidFormat", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to با موفقیت انجام شد.
|
||||
/// </summary>
|
||||
internal static string Success {
|
||||
get {
|
||||
return ResourceManager.GetString("Success", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to عملیات نامشخص.
|
||||
/// </summary>
|
||||
internal static string UnKnow {
|
||||
get {
|
||||
return ResourceManager.GetString("UnKnow", resourceCulture);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,141 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<data name="ConflictIdMission" xml:space="preserve">
|
||||
<value>شناسه تکراری میباشد</value>
|
||||
</data>
|
||||
<data name="ConflictUserName" xml:space="preserve">
|
||||
<value>نام کاربری تکراری میباشد</value>
|
||||
</data>
|
||||
<data name="DataNotComplete" xml:space="preserve">
|
||||
<value>دیتا کامل نمیباشد لطفا {0} را پر کیند</value>
|
||||
</data>
|
||||
<data name="Error" xml:space="preserve">
|
||||
<value>عملیات با خطا مواجه شد</value>
|
||||
</data>
|
||||
<data name="InvalidFormat" xml:space="preserve">
|
||||
<value>فرمت نامعتبر میباشد</value>
|
||||
</data>
|
||||
<data name="Success" xml:space="preserve">
|
||||
<value>با موفقیت انجام شد</value>
|
||||
</data>
|
||||
<data name="UnKnow" xml:space="preserve">
|
||||
<value>عملیات نامشخص</value>
|
||||
</data>
|
||||
</root>
|
||||
@@ -0,0 +1,31 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web;
|
||||
|
||||
namespace BlazorApp.Core.Security
|
||||
{
|
||||
public static class PasswordHelper
|
||||
{
|
||||
|
||||
|
||||
|
||||
public static string EncodePasswordMd5(string pass) //Encrypt using MD5
|
||||
{
|
||||
Byte[] originalBytes;
|
||||
Byte[] encodedBytes;
|
||||
MD5 md5;
|
||||
//Instantiate MD5CryptoServiceProvider, get bytes for original password and compute hash (encoded password)
|
||||
md5 = new MD5CryptoServiceProvider();
|
||||
originalBytes = ASCIIEncoding.Default.GetBytes(pass);
|
||||
encodedBytes = md5.ComputeHash(originalBytes);
|
||||
//Convert encoded bytes back to a 'readable' string
|
||||
return BitConverter.ToString(encodedBytes);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc.Filters;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
using BlazorApp.Core.Services;
|
||||
|
||||
namespace BlazorApp.Core.Security
|
||||
{
|
||||
public class PermissionChekAttribute : AuthorizeAttribute, IAuthorizationFilter
|
||||
{
|
||||
IPermissionService _permissionService;
|
||||
int _permissionId = 0;
|
||||
private int _subPermission = 0;
|
||||
|
||||
|
||||
public PermissionChekAttribute(int subPermission,int permissionId)
|
||||
{
|
||||
_permissionId = permissionId;
|
||||
_subPermission = subPermission;
|
||||
}
|
||||
public void OnAuthorization(AuthorizationFilterContext context)
|
||||
{
|
||||
_permissionService = (PermissionService)context
|
||||
.HttpContext
|
||||
.RequestServices
|
||||
.GetService(typeof(IPermissionService));
|
||||
|
||||
if (context.HttpContext.User.Identity.IsAuthenticated)
|
||||
{
|
||||
string userName = context.HttpContext.User.Identity.Name;
|
||||
|
||||
|
||||
|
||||
string per = context.HttpContext.User.FindFirst("Permission").Value.ToString();
|
||||
|
||||
if (_subPermission == 1)
|
||||
{
|
||||
if (!_permissionService.ChekPermission(userName, _permissionId))
|
||||
{
|
||||
context.Result = new RedirectResult("/Login");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (int.Parse(per) != _subPermission)
|
||||
{
|
||||
context.Result = new RedirectResult("/Login");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
context.Result = new RedirectResult("/Login");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
using Microsoft.AspNetCore.Http;
|
||||
|
||||
namespace BlazorApp.Core
|
||||
{
|
||||
public static class ImageFile
|
||||
{
|
||||
static Core.WorkFile wk = new WorkFile("wwwroot/UserImages");
|
||||
public static void DeleteImage(string imgName)
|
||||
{
|
||||
wk.DelteFile(imgName);
|
||||
}
|
||||
public static void AddImage(IFormFile file, string newName = null)
|
||||
{
|
||||
wk.AddFile(file, newName);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using System.IO;
|
||||
|
||||
namespace BlazorApp.Core
|
||||
{
|
||||
public class WorkFile
|
||||
{
|
||||
public WorkFile(string wwwroot)
|
||||
{
|
||||
_path = Path.Combine(Directory.GetCurrentDirectory(), wwwroot);
|
||||
}
|
||||
private static string _path;
|
||||
public bool DelteFile(string fileName)
|
||||
{
|
||||
try
|
||||
{
|
||||
string path = Path.Combine(_path, fileName);
|
||||
if (File.Exists(path))
|
||||
{
|
||||
File.Delete(path);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public bool AddFile(IFormFile file, string newName = null)
|
||||
{
|
||||
try
|
||||
{
|
||||
string fileName = file.FileName;
|
||||
if (!string.IsNullOrEmpty(newName))
|
||||
{
|
||||
fileName = newName;
|
||||
}
|
||||
string filePath = Path.Combine(_path, fileName);
|
||||
using (FileStream fileStream = new FileStream(filePath, FileMode.Create))
|
||||
{
|
||||
file.CopyTo(fileStream);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static string formatFile(IFormFile file)
|
||||
{
|
||||
return Path.GetExtension(file.FileName);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,116 @@
|
||||
using BlazorApp.Core.Services.Modern;
|
||||
using BlazorApp.DataLayer.Context;
|
||||
using BlazorApp.DataLayer.Entities.Colleges;
|
||||
|
||||
namespace BlazorApp.Core.Services
|
||||
{
|
||||
public partial class CollegeService : GenericRepositoryModern<College>, ICollegeService
|
||||
{
|
||||
private BPOB_Context _context;
|
||||
public CollegeService(BPOB_Context context) : base(context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
public ServiceResponse<List<College>> GetAllColleges()
|
||||
{
|
||||
var item = new ServiceResponse<List<College>>();
|
||||
|
||||
try
|
||||
{
|
||||
item.SetData(_context.Colleges.ToList());
|
||||
item.SetStatus(ResultStatus.Success);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
item.Status = ResultStatus.Error;
|
||||
item.SetException(ex);
|
||||
throw;
|
||||
}
|
||||
return item;
|
||||
|
||||
}
|
||||
|
||||
public ServiceResponse<College> DeleteCollege(int collegeId)
|
||||
{
|
||||
var item = new ServiceResponse<College>();
|
||||
College college = new College();
|
||||
try
|
||||
{
|
||||
college = _context.Colleges.Find(collegeId);
|
||||
_context.Colleges.Remove(college);
|
||||
_context.SaveChanges();
|
||||
item.SetData(college);
|
||||
item.Status = ResultStatus.Success;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
item.SetException(ex);
|
||||
item.Status = ResultStatus.Error;
|
||||
throw;
|
||||
}
|
||||
return item;
|
||||
}
|
||||
|
||||
|
||||
public ServiceResponse<College> CreateCollege(College college)
|
||||
{
|
||||
var item = new ServiceResponse<College>();
|
||||
try
|
||||
{
|
||||
_context.Colleges.Add(college);
|
||||
_context.SaveChanges();
|
||||
item.SetStatus(ResultStatus.Success);
|
||||
item.SetData(college);
|
||||
item.SetStatus(ResultStatus.Success) ;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
item.ErrorException = ex;
|
||||
item.SetData(college);
|
||||
item.SetStatus(ResultStatus.Error);
|
||||
}
|
||||
return item;
|
||||
}
|
||||
|
||||
public ServiceResponse<College> UpdateCollege(College college)
|
||||
{
|
||||
var item = new ServiceResponse<College>();
|
||||
try
|
||||
{
|
||||
_context.Colleges.Update(college);
|
||||
_context.SaveChanges();
|
||||
item.SetData(college);
|
||||
item.SetStatus(ResultStatus.Success);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
item.SetData(college);
|
||||
item.ErrorException = ex;
|
||||
item.SetStatus(ResultStatus.Error) ;
|
||||
}
|
||||
return item;
|
||||
}
|
||||
|
||||
public ServiceResponse<College> GetCollegeById(int collegeId)
|
||||
{
|
||||
var item = new ServiceResponse<College>();
|
||||
try
|
||||
{
|
||||
item.SetData(_context.Colleges.Find(collegeId));
|
||||
item.SetStatus(ResultStatus.Success);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
item.SetException(ex);
|
||||
item.SetStatus(ResultStatus.Error);
|
||||
}
|
||||
return item;
|
||||
}
|
||||
|
||||
public bool Close()
|
||||
{
|
||||
_context.SaveChanges();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,151 @@
|
||||
using BlazorApp.Core.DTOs;
|
||||
using BlazorApp.DataLayer.Entities.Colleges;
|
||||
using BlazorApp.DataLayer.Entities.OrganizationalUnits;
|
||||
using BlazorApp.DataLayer.Entities;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using BlazorApp.DataLayer.Entities.Colleges.Schedule;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using BlazorApp.Core.Tool;
|
||||
|
||||
namespace BlazorApp.Core.Services
|
||||
{
|
||||
public partial class CollegeService
|
||||
{
|
||||
public async Task<ServiceResponseByNumber<List<ConfrimCollegeRequestForAdminViewModel>>> ConfirmRequestForAdmin(List<YearOfPlan> plans, List<Month> months, List<OrganizationalUnit> units, List<College> colleges, bool forConfirm, int pageSize = 10, int pageNunmber = 0)
|
||||
{
|
||||
ServiceResponseByNumber<List<ConfrimCollegeRequestForAdminViewModel>> dt = new ServiceResponseByNumber<List<ConfrimCollegeRequestForAdminViewModel>>();
|
||||
|
||||
List<ConfrimCollegeRequestForAdminViewModel> lst = new List<ConfrimCollegeRequestForAdminViewModel>();
|
||||
|
||||
NumberResponse<IEnumerable<ConfrimCollegeRequestForAdminViewModel>> mmdi = new NumberResponse<IEnumerable<ConfrimCollegeRequestForAdminViewModel>>();
|
||||
|
||||
if (forConfirm)
|
||||
{
|
||||
var request = await _context.RequestsFromColleges.Where( i =>
|
||||
i.OU_Amount != 0
|
||||
)/*.Take(pageSize * (pageNunmber + 1))*/.ToListAsync();
|
||||
foreach(var req in request)
|
||||
{
|
||||
var schedule = GetScheduleOfCollege(req.ScheduleId).Data;
|
||||
|
||||
|
||||
|
||||
if (plans.Any(p => p.YearId == schedule.YearId) && colleges.Any(c => c.CollegeId == schedule.CollegeId) && units.Any(u => u.OU_Id == schedule.ScheduleText.OuId) && months.Any(m => m.MonthId == req.MonthId))
|
||||
{
|
||||
var confirm = new ConfrimCollegeRequestForAdminViewModel();
|
||||
confirm.ScheduleTitle = schedule.ScheduleText.ScheduleTextTitle;
|
||||
confirm.CollegeTitle = schedule.College.CollegeTitle;
|
||||
confirm.UnitTitle = schedule.ScheduleText.OU.OU_Title;
|
||||
confirm.MonthTitle = req.Month.MonthTitle;
|
||||
confirm.Request = req;
|
||||
confirm.YearNumber = schedule.YearOfPlan.YearNumber.ToString();
|
||||
lst.Add(confirm);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
List<ScheduleOfCollege> schedules = await _context.ScheduleOfColleges.Where(s =>
|
||||
colleges.Contains(s.College) && plans.Contains(s.YearOfPlan) && units.Contains(s.ScheduleText.OU)
|
||||
)/*.Take(pageSize * (pageNunmber + 1))*/.Include(s => s.ScheduleText).ToListAsync();
|
||||
|
||||
foreach (var schedule in schedules)
|
||||
{
|
||||
foreach(var month in months)
|
||||
{
|
||||
var request = _context.RequestsFromColleges.Where(r => r.ScheduleId == schedule.ScheduleId && r.MonthId == month.MonthId).SingleOrDefault();
|
||||
|
||||
if(request != null)
|
||||
{
|
||||
var confirm = new ConfrimCollegeRequestForAdminViewModel();
|
||||
confirm.ScheduleTitle = schedule.ScheduleText.ScheduleTextTitle;
|
||||
confirm.CollegeTitle = schedule.College.CollegeTitle;
|
||||
confirm.UnitTitle = schedule.ScheduleText.OU.OU_Title;
|
||||
confirm.MonthTitle = month.MonthTitle;
|
||||
confirm.Request = request;
|
||||
confirm.YearNumber = schedule.YearOfPlan.YearNumber.ToString();
|
||||
lst.Add(confirm);
|
||||
}
|
||||
else
|
||||
{
|
||||
request = new RequestFromCollege();
|
||||
request.MonthId = month.MonthId;
|
||||
request.ScheduleId = schedule.ScheduleId;
|
||||
request.AllocationAmount = GetMonthAmountForScheduleCollege(schedule.ScheduleId,month.MonthId);
|
||||
request.RequestAmount = 0;
|
||||
request.OU_Amount = 0;
|
||||
request.ManagerAmount = 0;
|
||||
request.PaymentAmount = 0;
|
||||
var confirm = new ConfrimCollegeRequestForAdminViewModel();
|
||||
confirm.ScheduleTitle = schedule.ScheduleText.ScheduleTextTitle;
|
||||
confirm.CollegeTitle = schedule.College.CollegeTitle;
|
||||
confirm.UnitTitle = schedule.ScheduleText.OU.OU_Title;
|
||||
confirm.MonthTitle = month.MonthTitle;
|
||||
confirm.Request = request;
|
||||
confirm.YearNumber = schedule.YearOfPlan.YearNumber.ToString();
|
||||
lst.Add(confirm);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//var request = _context.RequestsFromColleges.Where(r => r.ScheduleId == schedule.ScheduleId).SingleOrDefault();
|
||||
//if(request != null)
|
||||
//{
|
||||
// if (months.Any(m => m.MonthId == request.MonthId))
|
||||
// {
|
||||
// var confirm = new ConfrimCollegeRequestForAdminViewModel();
|
||||
// confirm.ScheduleTitle = schedule.ScheduleText.ScheduleTextTitle;
|
||||
// confirm.CollegeTitle = schedule.College.CollegeTitle;
|
||||
// confirm.UnitTitle = schedule.ScheduleText.OU.OU_Title;
|
||||
// confirm.MonthTitle = request.Month.MonthTitle;
|
||||
// confirm.Request = request;
|
||||
// confirm.YearNumber = schedule.YearOfPlan.YearNumber.ToString();
|
||||
// lst.Add(confirm);
|
||||
// }
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// request = new RequestFromCollege();
|
||||
// foreach()
|
||||
// {
|
||||
|
||||
// }
|
||||
// request.AllocationAmount = GetMonthAmountForScheduleCollege(schedule.ScheduleId,);
|
||||
//}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
List<ConfrimCollegeRequestForAdminViewModel> data = new List<ConfrimCollegeRequestForAdminViewModel>();
|
||||
if(pageSize == 0)
|
||||
{
|
||||
data = lst.ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
data = lst.Take(pageSize * (pageNunmber + 1)).ToList();
|
||||
}
|
||||
dt.SetData(data);
|
||||
dt.SetNumber(lst.Count());
|
||||
return dt;
|
||||
|
||||
//return lst.Take(pageSize * (pageNunmber + 1));
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
using BlazorApp.Core.DTOs;
|
||||
using BlazorApp.DataLayer.Entities.Colleges.Schedule;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BlazorApp.Core.Services
|
||||
{
|
||||
public partial class OU_Service
|
||||
{
|
||||
public List<ConfirmRequestForOuViewModel> GetSchedulesOfCollegeForConfirm(int ouId, int planId, int monthId, int collegeId)
|
||||
{
|
||||
var SchedulesOfCollege = _context.ScheduleOfColleges.Where( i =>
|
||||
i.ScheduleText.OuId == ouId && i.YearId == planId && i.CollegeId == collegeId
|
||||
).Include(i => i.ScheduleText).ToList();
|
||||
|
||||
List<ConfirmRequestForOuViewModel> lst = new List<ConfirmRequestForOuViewModel>();
|
||||
|
||||
foreach(var item in SchedulesOfCollege)
|
||||
{
|
||||
ConfirmRequestForOuViewModel confirm = new ConfirmRequestForOuViewModel();
|
||||
confirm.ScheduleId = item.ScheduleId;
|
||||
confirm.ScheduleTitle = item.ScheduleText.ScheduleTextTitle;
|
||||
confirm.MonthId = monthId;
|
||||
|
||||
RequestFromCollege req = GetRequestFromCollege(monthId,item.ScheduleId);
|
||||
|
||||
if(req == null)
|
||||
{
|
||||
req = new RequestFromCollege();
|
||||
req.ScheduleId = item.ScheduleId;
|
||||
req.MonthId = monthId;
|
||||
req.RequestAmount = 0;
|
||||
req.OU_Amount = 0;
|
||||
req.ManagerAmount = 0;
|
||||
req.PaymentAmount = 0;
|
||||
switch (monthId)
|
||||
{
|
||||
case 1:
|
||||
req.AllocationAmount = item.Farvardin;
|
||||
break;
|
||||
case 2:
|
||||
req.AllocationAmount = item.Ordibehesht;
|
||||
break;
|
||||
case 3:
|
||||
req.AllocationAmount = item.Khordad;
|
||||
break;
|
||||
case 4:
|
||||
req.AllocationAmount = item.Tir;
|
||||
break;
|
||||
case 5:
|
||||
req.AllocationAmount = item.Mordad;
|
||||
break;
|
||||
case 6:
|
||||
req.AllocationAmount = item.Shahrivar;
|
||||
break;
|
||||
case 7:
|
||||
req.AllocationAmount = item.Mehr;
|
||||
break;
|
||||
case 8:
|
||||
req.AllocationAmount = item.Aban;
|
||||
break;
|
||||
case 9:
|
||||
req.AllocationAmount = item.Azar;
|
||||
break;
|
||||
case 10:
|
||||
req.AllocationAmount = item.Dey;
|
||||
break;
|
||||
case 11:
|
||||
req.AllocationAmount = item.Bahman;
|
||||
break;
|
||||
case 12:
|
||||
req.AllocationAmount = item.Esfand;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
confirm.Request = req;
|
||||
lst.Add(confirm);
|
||||
}
|
||||
|
||||
return lst;
|
||||
|
||||
}
|
||||
|
||||
RequestFromCollege GetRequestFromCollege(int monthId,int scheduleId)
|
||||
{
|
||||
return _context.RequestsFromColleges.Where(i => i.MonthId == monthId && i.ScheduleId == scheduleId).SingleOrDefault();
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
using BlazorApp.Core.DTOs;
|
||||
using BlazorApp.DataLayer.Entities.OrganizationalUnits;
|
||||
using BlazorApp.DataLayer.Entities;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace BlazorApp.Core.Services
|
||||
{
|
||||
public partial class OU_Service
|
||||
{
|
||||
public async Task<ServiceResponseByNumber<List<ConfirmUnitRequestForAdminViewModel>>> ConfirmRequestForAdmin(List<YearOfPlan> plans, List<Month> months, List<OrganizationalUnit> units, bool onlyConfirm,int pageSize = 10,int pageNumber = 0)
|
||||
{
|
||||
ServiceResponseByNumber<List<ConfirmUnitRequestForAdminViewModel>> res = new ServiceResponseByNumber<List<ConfirmUnitRequestForAdminViewModel>>();
|
||||
List<ConfirmUnitRequestForAdminViewModel> lst = new List<ConfirmUnitRequestForAdminViewModel>();
|
||||
if (onlyConfirm)
|
||||
{
|
||||
var requests = await _context.RequestsFromUnits.Where(r =>
|
||||
plans.Contains(r.Schedule.YearOfPlan) && months.Contains(r.Month) && units.Contains(r.Schedule.OU) && r.RequestAmount != 0
|
||||
|
||||
)/*.Take(pageSize * (pageNumber + 1))*/.Include(r => r.Schedule).ToListAsync();
|
||||
|
||||
foreach (var r in requests)
|
||||
{
|
||||
var schedule = GetScheduleOfOu(r.ScheduleId);
|
||||
|
||||
ConfirmUnitRequestForAdminViewModel confirm = new ConfirmUnitRequestForAdminViewModel();
|
||||
confirm.YearNumber = schedule.YearOfPlan.YearNumber.ToString();
|
||||
confirm.UnitTitle = schedule.OU.OU_Title;
|
||||
confirm.ScheduleTitle = schedule.ScheduleText.ScheduleTextTitle;
|
||||
confirm.MonthTitle = r.Month.MonthTitle;
|
||||
confirm.Request = r;
|
||||
lst.Add(confirm);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var schedules = await _context.SchedulesOf_OU.Where(s =>
|
||||
plans.Contains(s.YearOfPlan) && units.Contains(s.OU)
|
||||
).Include(s => s.ScheduleText)/*.Take(pageSize * (pageNumber + 1))*/.ToListAsync();
|
||||
|
||||
|
||||
foreach (var schedule in schedules)
|
||||
{
|
||||
foreach (var month in months)
|
||||
{
|
||||
var request = GetRequest(schedule.ScheduleId,month.MonthId);
|
||||
if(request != null)
|
||||
{
|
||||
ConfirmUnitRequestForAdminViewModel confirm = new ConfirmUnitRequestForAdminViewModel();
|
||||
confirm.YearNumber = schedule.YearOfPlan.YearNumber.ToString();
|
||||
confirm.UnitTitle = schedule.OU.OU_Title;
|
||||
confirm.ScheduleTitle = schedule.ScheduleText.ScheduleTextTitle;
|
||||
confirm.MonthTitle = request.Month.MonthTitle;
|
||||
confirm.Request = request;
|
||||
lst.Add(confirm);
|
||||
}
|
||||
else
|
||||
{
|
||||
request = new RequestFromUnit();
|
||||
request.AllocationAmount = GetMonthAmountForScheduleOu(schedule.ScheduleId,month.MonthId);
|
||||
request.RequestAmount = 0;
|
||||
request.ManagerAmount = 0;
|
||||
request.PaymentAmount = 0;
|
||||
request.Month = month;
|
||||
request.MonthId = month.MonthId;
|
||||
request.ScheduleId = schedule.ScheduleId;
|
||||
request.Schedule = schedule;
|
||||
|
||||
ConfirmUnitRequestForAdminViewModel confirm = new ConfirmUnitRequestForAdminViewModel();
|
||||
confirm.YearNumber = schedule.YearOfPlan.YearNumber.ToString();
|
||||
confirm.UnitTitle = schedule.OU.OU_Title;
|
||||
confirm.ScheduleTitle = schedule.ScheduleText.ScheduleTextTitle;
|
||||
confirm.MonthTitle = request.Month.MonthTitle;
|
||||
confirm.Request = request;
|
||||
lst.Add(confirm);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
if(pageSize == 0)
|
||||
{
|
||||
res.SetData(lst.ToList());
|
||||
}
|
||||
else
|
||||
{
|
||||
res.SetData(lst.Take(pageSize * (pageNumber + 1)).ToList());
|
||||
}
|
||||
res.Number = lst.Count();
|
||||
return res;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
using BlazorApp.Core.DTOs;
|
||||
using BlazorApp.DataLayer.Entities.Users;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BlazorApp.Core.Services
|
||||
{
|
||||
public partial class UserService:IUserService
|
||||
{
|
||||
|
||||
public List<EducationOfUser> GetAllEducations()
|
||||
{
|
||||
return _context.EducationOfUsers.ToList();
|
||||
}
|
||||
|
||||
|
||||
public User GetUserByLoginViewModel(LoginViewModel login)
|
||||
{
|
||||
return _context.Users.Where(u => u.UserName == login.UserName && u.Password == login.Password).FirstOrDefault();
|
||||
}
|
||||
|
||||
public ServiceResponse<EducationOfUser> CreateEducation(EducationOfUser education)
|
||||
{
|
||||
var item = new ServiceResponse<EducationOfUser>();
|
||||
try
|
||||
{
|
||||
_context.EducationOfUsers.Add(education);
|
||||
_context.SaveChanges();
|
||||
item.SetData(education);
|
||||
item.SetStatus(ResultStatus.Success);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
item.SetException(ex);
|
||||
item.SetData(education);
|
||||
item.SetStatus(ResultStatus.Error);
|
||||
}
|
||||
return item;
|
||||
}
|
||||
|
||||
public ServiceResponse<EducationOfUser> UpdateEducation(EducationOfUser education)
|
||||
{
|
||||
|
||||
var item = new ServiceResponse<EducationOfUser>();
|
||||
try
|
||||
{
|
||||
_context.EducationOfUsers.Update(education);
|
||||
_context.SaveChanges();
|
||||
item.SetData(education);
|
||||
item.SetStatus(ResultStatus.Success);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
item.SetException(ex);
|
||||
item.SetData(education);
|
||||
item.SetStatus(ResultStatus.Error);
|
||||
}
|
||||
return item;
|
||||
}
|
||||
|
||||
public ServiceResponse<EducationOfUser> DeleteEducation(EducationOfUser education)
|
||||
{
|
||||
|
||||
var item = new ServiceResponse<EducationOfUser>();
|
||||
try
|
||||
{
|
||||
_context.EducationOfUsers.Remove(education);
|
||||
_context.SaveChanges();
|
||||
item.SetData(education);
|
||||
item.SetStatus(ResultStatus.Success);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
item.SetException(ex);
|
||||
item.SetData(education);
|
||||
item.SetStatus(ResultStatus.Error);
|
||||
}
|
||||
return item;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
using BlazorApp.DataLayer.Context;
|
||||
using BlazorApp.DataLayer.Entities;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BlazorApp.Core.Services
|
||||
{
|
||||
public class GeneralService : IGeneralService
|
||||
{
|
||||
private BPOB_Context _context;
|
||||
public GeneralService(BPOB_Context context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
public ServiceResponse<AppType> CreateAppType(AppType appType)
|
||||
{
|
||||
var item = new ServiceResponse<AppType>();
|
||||
try
|
||||
{
|
||||
_context.AppTypes.Add(appType);
|
||||
_context.SaveChanges();
|
||||
item.SetData(appType);
|
||||
item.SetStatus(ResultStatus.Success);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
item.SetException(ex);
|
||||
item.SetStatus(ResultStatus.Error);
|
||||
item.SetData(appType);
|
||||
}
|
||||
return item;
|
||||
}
|
||||
|
||||
public ServiceResponse<AppType> DeleteAppType(AppType appType)
|
||||
{
|
||||
var item = new ServiceResponse<AppType>();
|
||||
try
|
||||
{
|
||||
_context.AppTypes.Remove(appType);
|
||||
_context.SaveChanges();
|
||||
item.SetData(appType);
|
||||
item.SetStatus(ResultStatus.Success);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
item.SetException(ex);
|
||||
item.SetStatus(ResultStatus.Error);
|
||||
item.SetData(appType);
|
||||
}
|
||||
return item;
|
||||
}
|
||||
|
||||
public List<AppType> GetAllAppTypes()
|
||||
{
|
||||
return _context.AppTypes.ToList();
|
||||
}
|
||||
|
||||
public List<Level> GetAllLevels()
|
||||
{
|
||||
return _context.Levels.ToList();
|
||||
}
|
||||
|
||||
public ServiceResponse<AppType> GetAppType(int appTypeId)
|
||||
{
|
||||
var item = new ServiceResponse<AppType>();
|
||||
try
|
||||
{
|
||||
item.SetData(_context.AppTypes.Find(appTypeId));
|
||||
item.SetStatus(ResultStatus.Success);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
item.SetException(ex);
|
||||
item.SetStatus(ResultStatus.Error);
|
||||
}
|
||||
return item;
|
||||
}
|
||||
|
||||
public ServiceResponse<AppType> UpdateAppType(AppType appType)
|
||||
{
|
||||
var item = new ServiceResponse<AppType>();
|
||||
try
|
||||
{
|
||||
_context.AppTypes.Update(appType);
|
||||
_context.SaveChanges();
|
||||
item.SetData(appType);
|
||||
item.SetStatus(ResultStatus.Success);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
item.SetException(ex);
|
||||
item.SetStatus(ResultStatus.Error);
|
||||
item.SetData(appType);
|
||||
}
|
||||
return item;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
using BlazorApp.DataLayer.Context;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BlazorApp.Core.Services
|
||||
{
|
||||
public class GenericRepository<T> : IGenericRepository<T> where T : class
|
||||
{
|
||||
private BPOB_Context context;
|
||||
private DbSet<T> dbset;
|
||||
|
||||
public GenericRepository(BPOB_Context context)
|
||||
{
|
||||
this.context = context;
|
||||
dbset = context.Set<T>();
|
||||
}
|
||||
|
||||
public ServiceResponse<T> Create(T item)
|
||||
{
|
||||
var result = new ServiceResponse<T>();
|
||||
try
|
||||
{
|
||||
dbset.Add(item);
|
||||
context.SaveChanges();
|
||||
result.SetData(item);
|
||||
result.SetStatus(ResultStatus.Success);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
result.SetStatus(ResultStatus.Error);
|
||||
result.SetException(ex);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public ServiceResponse<T> Delete(T item)
|
||||
{
|
||||
var result = new ServiceResponse<T>();
|
||||
try
|
||||
{
|
||||
result.SetData(item);
|
||||
dbset.Remove(item);
|
||||
context.SaveChanges();
|
||||
result.SetStatus(ResultStatus.Success);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
result.SetData(item);
|
||||
result.SetStatus(ResultStatus.Error);
|
||||
result.SetException(ex);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public List<T> GetAllItem(Expression<Func<T, bool>>? expression = null)
|
||||
{
|
||||
return dbset.ToList();
|
||||
}
|
||||
|
||||
public T GetItem(int itemId)
|
||||
{
|
||||
return dbset.Find(itemId);
|
||||
}
|
||||
|
||||
public ServiceResponse<T> Update(T item)
|
||||
{
|
||||
var result = new ServiceResponse<T>();
|
||||
try
|
||||
{
|
||||
dbset.Update(item);
|
||||
context.SaveChanges();
|
||||
result.SetData(item);
|
||||
result.SetStatus(ResultStatus.Success);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
result.SetStatus(ResultStatus.Error);
|
||||
result.SetException(ex);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,250 @@
|
||||
using BlazorApp.DataLayer.Context;
|
||||
using BlazorApp.DataLayer.Entities.Guideline;
|
||||
using BlazorApp.DataLayer.Entities.RelationTargetAndGuideline;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using BlazorApp.DataLayer.Entities.Plans;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
|
||||
namespace BlazorApp.Core.Services
|
||||
{
|
||||
public class GuideLineService : IGuideLineService
|
||||
{
|
||||
private BPOB_Context _context;
|
||||
public GuideLineService(BPOB_Context context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
public List<Guideline> GetAllGuideLineOfTarget(int targetId)
|
||||
{
|
||||
return _context.RelationTargetAndGuidelines.Where(g => g.TargetId == targetId).Select(g => g.Guideline).ToList();
|
||||
}
|
||||
|
||||
public List<Guideline> GetGuideLineWithoutTarget(int targetId)
|
||||
{
|
||||
|
||||
|
||||
|
||||
var lst3 = GetAllGuideLineOfTarget(targetId);
|
||||
|
||||
var nlst = _context.Guidelines.ToList();
|
||||
var nlst2 = nlst.ToList();
|
||||
foreach (var i in nlst2)
|
||||
{
|
||||
if(lst3.Any(e => e.Id == i.Id))
|
||||
{
|
||||
nlst.Remove(i);
|
||||
}
|
||||
}
|
||||
return nlst;
|
||||
|
||||
List<RelationTargetAndGuideline> lst = _context.RelationTargetAndGuidelines.ToList();
|
||||
var helpLst = lst.ToList();
|
||||
|
||||
foreach(var item in helpLst)
|
||||
{
|
||||
if( lst3.Any(i => i.Id == item.GuidelineId))
|
||||
{
|
||||
lst.Remove(item);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
var lst2 = lst.DistinctBy(d => d.GuidelineId);
|
||||
|
||||
return lst2.Select(g => g.Guideline).ToList();
|
||||
|
||||
return _context.RelationTargetAndGuidelines.Where(g => g.TargetId != targetId).Select(g => g.Guideline).Distinct().ToList();
|
||||
}
|
||||
|
||||
public ServiceResponse<bool> UpdateGuideLinesOfTarget(List<Guideline> guideLines,int targetId)
|
||||
{
|
||||
var item = new ServiceResponse<bool>();
|
||||
try
|
||||
{
|
||||
var forDel = _context.RelationTargetAndGuidelines.Where(r => r.TargetId == targetId).ToList();
|
||||
foreach (var d in forDel)
|
||||
{
|
||||
_context.RelationTargetAndGuidelines.Remove(d);
|
||||
}
|
||||
|
||||
foreach(var a in guideLines)
|
||||
{
|
||||
RelationTargetAndGuideline r = new RelationTargetAndGuideline();
|
||||
r.TargetId = targetId;
|
||||
r.GuidelineId = a.Id;
|
||||
_context.RelationTargetAndGuidelines.Add(r);
|
||||
}
|
||||
_context.SaveChanges();
|
||||
item.SetData(true);
|
||||
item.SetStatus(ResultStatus.Success);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
item.SetException(ex);
|
||||
item.SetData(false);
|
||||
item.SetStatus(ResultStatus.Error) ;
|
||||
}
|
||||
return item;
|
||||
}
|
||||
|
||||
public List<Guideline> GetAllGuideline()
|
||||
{
|
||||
return _context.Guidelines.ToList();
|
||||
}
|
||||
|
||||
|
||||
public List<Plan> GetAllPlans()
|
||||
{
|
||||
return _context.Plans.Include(p => p.Guideline).ToList();
|
||||
}
|
||||
public List<Plan> GetPlansOfGuideline(int guidelineId)
|
||||
{
|
||||
return _context.Plans.Where(p => p.GuidelineId == guidelineId).ToList() ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public ServiceResponse<Guideline> CreateGuideline(Guideline guideline)
|
||||
{
|
||||
var item = new ServiceResponse<Guideline>();
|
||||
try
|
||||
{
|
||||
if(_context.Guidelines.Any(g => g.StrategyId == guideline.StrategyId))
|
||||
{
|
||||
item.SetStatus(ResultStatus.ConflictIdMission);
|
||||
item.SetData(guideline);
|
||||
return item;
|
||||
}
|
||||
_context.Guidelines.Add(guideline);
|
||||
_context.SaveChanges();
|
||||
item.SetData(guideline);
|
||||
item.SetStatus(ResultStatus.Success);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
item.SetData(guideline);
|
||||
item.SetStatus(ResultStatus.Error);
|
||||
item.SetException(ex);
|
||||
}
|
||||
return item;
|
||||
}
|
||||
|
||||
public ServiceResponse<bool> UpdateGuideline(Guideline guideline)
|
||||
{
|
||||
var item = new ServiceResponse<bool>();
|
||||
try
|
||||
{
|
||||
var old = _context.Guidelines.Where(g => g.StrategyId == guideline.StrategyId).SingleOrDefault();
|
||||
if(old != null)
|
||||
{
|
||||
if(old.Id != guideline.Id)
|
||||
{
|
||||
item.SetData(false);
|
||||
item.SetStatus(ResultStatus.ConflictIdMission);
|
||||
return item;
|
||||
}
|
||||
}
|
||||
_context.Guidelines.Update(guideline);
|
||||
_context.SaveChanges();
|
||||
item.SetData(true);
|
||||
item.SetStatus(ResultStatus.Success);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
item.SetData(false);
|
||||
item.SetStatus(ResultStatus.Error);
|
||||
item.SetException(ex);
|
||||
}
|
||||
return item;
|
||||
}
|
||||
|
||||
public ServiceResponse<bool> DeleteGuideline(Guideline guideline)
|
||||
{
|
||||
var item = new ServiceResponse<bool>();
|
||||
try
|
||||
{
|
||||
_context.Guidelines.Remove(guideline);
|
||||
_context.SaveChanges();
|
||||
item.SetData(true);
|
||||
item.SetStatus(ResultStatus.Success);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
item.SetData(false);
|
||||
item.SetStatus(ResultStatus.Error);
|
||||
item.SetException(ex);
|
||||
}
|
||||
return item;
|
||||
}
|
||||
|
||||
public ServiceResponse<Plan> CreatePlan(Plan plan)
|
||||
{
|
||||
var item = new ServiceResponse<Plan>();
|
||||
try
|
||||
{
|
||||
_context.Plans.Add(plan);
|
||||
_context.SaveChanges();
|
||||
item.SetData(plan);
|
||||
item.SetStatus(ResultStatus.Success);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
item.SetData(plan);
|
||||
item.SetStatus(ResultStatus.Error);
|
||||
item.SetException(ex);
|
||||
}
|
||||
return item;
|
||||
}
|
||||
|
||||
public ServiceResponse<bool> UpdateGuideline(Guideline guideline, List<Plan> plans)
|
||||
{
|
||||
var item = new ServiceResponse<bool>();
|
||||
try
|
||||
{
|
||||
|
||||
bool resul = _context.Guidelines.Any(g => g.StrategyId == guideline.StrategyId && g.Id != guideline.Id);
|
||||
if (resul)
|
||||
{
|
||||
item.SetData(false);
|
||||
item.SetStatus(ResultStatus.ConflictIdMission);
|
||||
return item;
|
||||
}
|
||||
|
||||
//if (old.Count() != 0)
|
||||
//{
|
||||
// if (old.Any(o => o.Id != guideline.Id))
|
||||
// {
|
||||
// item.SetData(false);
|
||||
// item.SetStatus(ResultStatus.ConflictIdMission);
|
||||
// return item;
|
||||
// }
|
||||
//}
|
||||
_context.Guidelines.Update(guideline);
|
||||
var deleteLst = _context.Plans.Where(p => p.GuidelineId == guideline.Id).ToList();
|
||||
_context.Plans.RemoveRange(deleteLst);
|
||||
_context.SaveChanges();
|
||||
foreach (var p in plans)
|
||||
{
|
||||
p.Id = 0;
|
||||
}
|
||||
_context.Plans.AddRange(plans);
|
||||
_context.SaveChanges();
|
||||
|
||||
item.SetData(true);
|
||||
item.SetStatus(ResultStatus.Success);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
item.SetException(ex);
|
||||
item.SetData(false);
|
||||
item.SetStatus(ResultStatus.Error);
|
||||
}
|
||||
return item;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
using BlazorApp.Core.DTOs;
|
||||
using BlazorApp.Core.Services.Interface;
|
||||
using BlazorApp.Core.Tool;
|
||||
using BlazorApp.DataLayer.Entities;
|
||||
using BlazorApp.DataLayer.Entities.Colleges;
|
||||
using BlazorApp.DataLayer.Entities.Colleges.Schedule;
|
||||
using BlazorApp.DataLayer.Entities.OrganizationalUnits;
|
||||
|
||||
namespace BlazorApp.Core.Services
|
||||
{
|
||||
public interface ICollegeService:IGenericRepositoryModern<College>
|
||||
{
|
||||
bool Close();
|
||||
ServiceResponse<List<College>> GetAllColleges();
|
||||
|
||||
ServiceResponse<College> GetCollegeById(int collegeId);
|
||||
ServiceResponse<College> DeleteCollege(int collegeId);
|
||||
ServiceResponse<College> CreateCollege(College college);
|
||||
|
||||
ServiceResponse<College> UpdateCollege(College college);
|
||||
|
||||
#region Schedule
|
||||
|
||||
|
||||
|
||||
|
||||
List<ScheduleOfCollege> GetSchedulesOfCollege(int collegeId,int planId);
|
||||
|
||||
|
||||
ServiceResponse<ScheduleOfCollege> GetScheduleOfCollege(int scheduleId);
|
||||
|
||||
ServiceResponse<ScheduleOfCollege> CreateScheduleOfCollege(ScheduleOfCollege schedule);
|
||||
|
||||
ServiceResponse<ScheduleOfCollege> UpdateScheduleOfCollege(ScheduleOfCollege schedule);
|
||||
|
||||
ServiceResponse<ScheduleOfCollege> DeleteScheduleOfCollege(ScheduleOfCollege schedule);
|
||||
|
||||
float GetScheduleOfCollegeTotalAmount(int scheduleId);
|
||||
|
||||
float GetMonthAmountForScheduleCollege(int scheduleId , int monthId);
|
||||
|
||||
float SumAmountOfMonth(ScheduleOfCollege schedule);
|
||||
|
||||
|
||||
#region ScheduleItem
|
||||
|
||||
ServiceResponse<RequestFromCollege> GetRequest(int scheduleId,int monthId);
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region RequestFormAdmin
|
||||
|
||||
Task<ServiceResponseByNumber<List<ConfrimCollegeRequestForAdminViewModel>>> ConfirmRequestForAdmin(List<YearOfPlan> plans,List<Month> months,List<OrganizationalUnit> units,List<College> colleges,bool forConfirm,int pageSize = 10,int pageNunmber = 0);
|
||||
|
||||
#endregion
|
||||
|
||||
#region NewSchedule
|
||||
IEnumerable<ScheduleOfCollegeByFilterViewModel> GetSchedulesOfCollege(int planId, int monthId,int ouId,int collegeId);
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
using BlazorApp.DataLayer.Entities;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BlazorApp.Core.Services
|
||||
{
|
||||
public interface IGeneralService
|
||||
{
|
||||
#region AppType
|
||||
List<AppType> GetAllAppTypes();
|
||||
|
||||
ServiceResponse<AppType> GetAppType(int appTypeId);
|
||||
|
||||
ServiceResponse<AppType> CreateAppType(AppType appType);
|
||||
|
||||
ServiceResponse<AppType> UpdateAppType(AppType appType);
|
||||
|
||||
ServiceResponse<AppType> DeleteAppType(AppType appType);
|
||||
|
||||
#endregion
|
||||
|
||||
#region Level
|
||||
List<Level> GetAllLevels();
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BlazorApp.Core.Services
|
||||
{
|
||||
public interface IGenericRepository<T>
|
||||
{
|
||||
List<T> GetAllItem(Expression<Func<T,bool>>? expression = null);
|
||||
|
||||
T GetItem(int itemId);
|
||||
|
||||
ServiceResponse<T> Create(T item);
|
||||
|
||||
ServiceResponse<T> Update(T item);
|
||||
|
||||
ServiceResponse<T> Delete(T item);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
using BlazorApp.DataLayer.Entities.Guideline;
|
||||
using BlazorApp.DataLayer.Entities.Plans;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BlazorApp.Core.Services
|
||||
{
|
||||
public interface IGuideLineService
|
||||
{
|
||||
List<Guideline> GetAllGuideLineOfTarget(int targetId);
|
||||
|
||||
List<Guideline> GetGuideLineWithoutTarget(int targetId);
|
||||
|
||||
ServiceResponse<bool> UpdateGuideLinesOfTarget(List<Guideline> guideLines, int targetId);
|
||||
|
||||
List<Guideline> GetAllGuideline();
|
||||
|
||||
|
||||
ServiceResponse<Guideline> CreateGuideline(Guideline guideline);
|
||||
|
||||
ServiceResponse<bool> UpdateGuideline(Guideline guideline);
|
||||
|
||||
ServiceResponse<bool> UpdateGuideline(Guideline guideline, List<Plan> plans);
|
||||
|
||||
ServiceResponse<bool> DeleteGuideline(Guideline guideline);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#region Plan
|
||||
List<Plan> GetAllPlans();
|
||||
List<Plan> GetPlansOfGuideline(int guidelineId);
|
||||
|
||||
ServiceResponse<Plan> CreatePlan(Plan plan);
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using BlazorApp.DataLayer.Entities.Mission;
|
||||
|
||||
namespace BlazorApp.Core.Services
|
||||
{
|
||||
public interface IMissionService
|
||||
{
|
||||
List<Mission> GetAllMission();
|
||||
|
||||
ServiceResponse<Mission> CreateMission(Mission mission);
|
||||
|
||||
ServiceResponse<Mission> UpdateMission(Mission mission);
|
||||
|
||||
ServiceResponse<Mission> DeleteMission(Mission mission);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using BlazorApp.Core.DTOs;
|
||||
using BlazorApp.DataLayer.Entities;
|
||||
using BlazorApp.DataLayer.Entities.Colleges.Schedule;
|
||||
using BlazorApp.DataLayer.Entities.OrganizationalUnits;
|
||||
namespace BlazorApp.Core.Services
|
||||
{
|
||||
public interface IOU_Service
|
||||
{
|
||||
List<OrganizationalUnit> GetAllOUs();
|
||||
|
||||
OrganizationalUnit GetOrganizationalUnit(int ouid);
|
||||
|
||||
ServiceResponse<OrganizationalUnit> CreateOU(OrganizationalUnit ou);
|
||||
|
||||
ServiceResponse<OrganizationalUnit> UpdateOU(OrganizationalUnit ou);
|
||||
|
||||
ServiceResponse<OrganizationalUnit> DeleteOU(OrganizationalUnit ou);
|
||||
|
||||
#region ScheduleTitle
|
||||
List<ScheduleText> GetAllScheduleTitle(int ouId);
|
||||
|
||||
ServiceResponse<ScheduleText> UpdateScheduleTitle(ScheduleText scheduleTitle);
|
||||
|
||||
ServiceResponse<ScheduleText> CreateScheduleTitle(ScheduleText scheduleTitle);
|
||||
|
||||
ServiceResponse<ScheduleText> DeleteScheduleTitle(ScheduleText scheduleTitle);
|
||||
|
||||
ServiceResponse<ScheduleText> GetScheduleTitleById(int scheduleTitleId);
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region ScheduleOU
|
||||
List<ScheduleOfOU> GetScheduleOfOus(int ouId, int planId);
|
||||
|
||||
float SumAmountOfMonth(ScheduleOfOU schedule);
|
||||
|
||||
ScheduleOfOU GetScheduleOfOu(int scheduleId);
|
||||
|
||||
ServiceResponse<ScheduleOfOU> CreateScheduleOfOu(ScheduleOfOU schedule);
|
||||
ServiceResponse <ScheduleOfOU> UpdateScheduleOfOu(ScheduleOfOU schedule);
|
||||
ServiceResponse<ScheduleOfOU> DeleteScheduleOfOu(ScheduleOfOU schedule);
|
||||
|
||||
|
||||
|
||||
RequestFromUnit GetRequest(int scheduleId,int monthId);
|
||||
|
||||
|
||||
float GetMonthAmountForScheduleOu(int scheduleId, int monthId);
|
||||
|
||||
float GetScheduleOfOuTotalAmount(int scheduleId);
|
||||
|
||||
#endregion
|
||||
|
||||
#region ConfirmRequest
|
||||
|
||||
Task<ServiceResponseByNumber<List<ConfirmUnitRequestForAdminViewModel>>> ConfirmRequestForAdmin(List<YearOfPlan> plans, List<Month> months,List<OrganizationalUnit> units,bool onlyConfirm,int pageSize = 10,int pageNumber = 0);
|
||||
|
||||
List<ConfirmRequestForOuViewModel> GetSchedulesOfCollegeForConfirm(int ouId,int planId,int monthId,int collegeId);
|
||||
|
||||
#endregion
|
||||
|
||||
#region ReportNumber
|
||||
ServiceResponse<int> AllRequestCount(int ouId);
|
||||
|
||||
ServiceResponse<int> YearRequestCount(int ouId, int yearId);
|
||||
|
||||
ServiceResponse<int> MonthRequestCount(int ouId,int yearId,int monthId);
|
||||
|
||||
ServiceResponse<int> CollegeRequestCount(int ouId,int yearId,int monthId,int collegeId);
|
||||
|
||||
#endregion
|
||||
|
||||
#region newSchedule
|
||||
Task<List<ScheduleOfOuByFilterViewModel>> GetSchedulesOfOu(int planId,int monthId,int ouId);
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using BlazorApp.DataLayer.Entities.Permissions;
|
||||
|
||||
namespace BlazorApp.Core.Services
|
||||
{
|
||||
public interface IPermissionService
|
||||
{
|
||||
#region Role
|
||||
Role GetRoleByRoleId(int roleId);
|
||||
#endregion
|
||||
List<Role> GetAllRoles();
|
||||
|
||||
List<Role> GetRolesOfUser(int userId);
|
||||
|
||||
ServiceResponse<bool> UpdateRolesOfUser(List<Role> roles, int userId);
|
||||
|
||||
ServiceResponse<Role> CreateRole(Role role);
|
||||
|
||||
ServiceResponse<Role> UpdateRole(Role role);
|
||||
|
||||
ServiceResponse<Role> DeleteRole(Role role);
|
||||
|
||||
bool CheckRole(int userId, int roleId);
|
||||
|
||||
#region Permission
|
||||
|
||||
List<Permission> GetAllPermissions();
|
||||
|
||||
List<Permission> GetPermissionsOfRole(int roleId);
|
||||
|
||||
ServiceResponse<bool> UpdatePermissionsOfRole(List<int> permissions, int roleId);
|
||||
|
||||
|
||||
List<CollegePermission> GetCollegePermissionsOfRole(int roleId);
|
||||
ServiceResponse<bool> UpdateCollegePermissionsOfRole(List<int> collegePermissions, int roleId);
|
||||
|
||||
|
||||
List<OuPermission> GetOuPermissionsOfRole(int roleId);
|
||||
ServiceResponse<bool> UpdateOuPermissionsOfRole(List<int> ouPermissions,int roleId);
|
||||
|
||||
#endregion
|
||||
|
||||
#region CollegePermission
|
||||
|
||||
bool CheckCollegePermission(int roleId, int collegeId);
|
||||
|
||||
List<CollegePermission> GetCollegePermissionOfRole(int roleId);
|
||||
|
||||
#endregion
|
||||
|
||||
#region OuPermission
|
||||
|
||||
bool CheckOuPermission(int roleId, int ouId);
|
||||
|
||||
|
||||
List<OuPermission> GetOuPermissionOfRole(int roleId);
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
bool CheckPermissionForRole(int roleId, int permissionId);
|
||||
|
||||
bool ChekPermission(string userName, int permissionId);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
using BlazorApp.Core.DTOs;
|
||||
using BlazorApp.DataLayer.Entities.TalentSearchs;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BlazorApp.Core.Services
|
||||
{
|
||||
public interface IPersonnelService:IGenericRepository<Personnel>
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
using BlazorApp.Core.DTOs;
|
||||
using BlazorApp.DataLayer.Entities;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BlazorApp.Core.Services
|
||||
{
|
||||
public interface IReportService
|
||||
{
|
||||
Task<List<ReportUnitViewModel>> GetReportUnit(List<YearOfPlan> plans,List<Month> months);
|
||||
|
||||
List<ReportUnitViewModel> GetReportUnit(List<YearOfPlan> plans,List<Month> months,int titleId);
|
||||
|
||||
List<ReportCollegeViewModel> GetReportCollege (List<YearOfPlan> plans, List<Month> months, int titleId);
|
||||
|
||||
|
||||
Task<MemoryStream> ConvertorExcel(List<YearOfPlan> plans,List<Month> months);
|
||||
|
||||
//Task<MemoryStream> ConvertScheduleOfCollegeToExcel();
|
||||
|
||||
Task<MemoryStream> ConvertScheduleOfOuToExcel(List<ScheduleOfOuByFilterViewModel> schedules,string plan,string month,string ouTitle);
|
||||
Task<MemoryStream> ConvertScheduleOfCoToExcel(List<ScheduleOfCollegeByFilterViewModel> schedules , string plan,string month,string college);
|
||||
|
||||
Task<MemoryStream> ConvertFundingLogToExcel(List<ConfrimCollegeRequestForAdminViewModel> logs , string plan,string month, string college,string ous);
|
||||
Task<MemoryStream> ConvertUnitLogToExcel(List<ConfirmUnitRequestForAdminViewModel> logs, string plan,string month,string ou );
|
||||
|
||||
float RequestReportOfUnit(List<YearOfPlan> plans, List<Month> months, int ouId);
|
||||
|
||||
float RequestReportOfCollege(List<YearOfPlan> plans, List<Month> months, int ouId,int collegeId);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using BlazorApp.DataLayer.Entities.Targets;
|
||||
|
||||
namespace BlazorApp.Core.Services
|
||||
{
|
||||
public interface ITargetService
|
||||
{
|
||||
Target GetTarget(int targetId);
|
||||
|
||||
ServiceResponse<Target> CreateTarget(Target target);
|
||||
|
||||
ServiceResponse<Target> UpdateTarget(Target target);
|
||||
|
||||
ServiceResponse<Target> DeleteTarget(Target target);
|
||||
|
||||
List<Target> GetAllTargets();
|
||||
|
||||
List<Target> GetTargetsOfGuideline(int guidelineId);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using BlazorApp.Core.DTOs;
|
||||
using BlazorApp.DataLayer.Entities.Users;
|
||||
using Microsoft.AspNetCore.Components.Forms;
|
||||
|
||||
namespace BlazorApp.Core.Services
|
||||
{
|
||||
public interface IUserService
|
||||
{
|
||||
#region Getuser
|
||||
User GetUserByUserName(string userName);
|
||||
#endregion
|
||||
List<User> GetAllUsers();
|
||||
|
||||
User GetUserById(int userId);
|
||||
|
||||
ServiceResponse<User> CreateUser(User user);
|
||||
|
||||
ServiceResponse<User> UpdateUser(User user);
|
||||
|
||||
ServiceResponse<User> DeleteUser(User user);
|
||||
|
||||
Task<ServiceResponse<string>> SetAvatar(InputFileChangeEventArgs file);
|
||||
|
||||
ServiceResponse<bool> RemoveAvatar(string imgName);
|
||||
|
||||
#region Permission
|
||||
User GetUserByLoginViewModel(LoginViewModel login);
|
||||
#endregion
|
||||
|
||||
#region Education
|
||||
List<EducationOfUser> GetAllEducations();
|
||||
|
||||
ServiceResponse<EducationOfUser> CreateEducation(EducationOfUser education);
|
||||
|
||||
ServiceResponse<EducationOfUser> UpdateEducation(EducationOfUser education);
|
||||
|
||||
ServiceResponse<EducationOfUser> DeleteEducation(EducationOfUser education);
|
||||
|
||||
#endregion
|
||||
|
||||
#region Marriage
|
||||
List<MarriageOfUser> GetAllMarriage();
|
||||
|
||||
ServiceResponse<MarriageOfUser> CreateMarriage(MarriageOfUser marriage);
|
||||
|
||||
ServiceResponse<MarriageOfUser> UpdateMarriage(MarriageOfUser marriage);
|
||||
|
||||
ServiceResponse<MarriageOfUser> DeleteMarriage(MarriageOfUser marriage);
|
||||
#endregion
|
||||
|
||||
#region ServiceLocation
|
||||
List<ServiceLocationOfUser> GetAllServiceLocations();
|
||||
|
||||
ServiceResponse<ServiceLocationOfUser> CreateServiceLocation(ServiceLocationOfUser serviceLocation);
|
||||
|
||||
ServiceResponse<ServiceLocationOfUser> UpdateServiceLocation(ServiceLocationOfUser serviceLocation);
|
||||
|
||||
ServiceResponse<ServiceLocationOfUser> DeleteServiceLocation(ServiceLocationOfUser serviceLocation);
|
||||
|
||||
#endregion
|
||||
|
||||
#region Profile
|
||||
|
||||
ServiceResponse<bool> UpdatePassword(UpdatePasswordViewModel userPassword);
|
||||
|
||||
ServiceResponse<bool> UpdateUserName(UpdateUserNameViewModel updateUserName);
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using BlazorApp.DataLayer.Entities.Vision;
|
||||
|
||||
namespace BlazorApp.Core.Services
|
||||
{
|
||||
public interface IVisionService
|
||||
{
|
||||
List<Vision> GetAllVisions();
|
||||
|
||||
ServiceResponse<Vision> CreateVision(Vision vision);
|
||||
|
||||
ServiceResponse<Vision> UpdateVision(Vision vision);
|
||||
|
||||
ServiceResponse<Vision> DeleteVision(Vision vision);
|
||||
|
||||
Vision GetVision(int visionId);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using BlazorApp.DataLayer.Entities;
|
||||
|
||||
namespace BlazorApp.Core.Services
|
||||
{
|
||||
public interface IYearOfPlanService
|
||||
{
|
||||
ServiceResponse<List<YearOfPlan>> GetAllPlans();
|
||||
|
||||
ServiceResponse<List<YearOfPlan>> GetShowPlans();
|
||||
|
||||
ServiceResponse<YearOfPlan> GetPlanById(int planId);
|
||||
|
||||
Task<ServiceResponse<YearOfPlan>> CreatePlan(YearOfPlan plan);
|
||||
|
||||
ServiceResponse<YearOfPlan> DeletePlan(YearOfPlan plan);
|
||||
|
||||
ServiceResponse<YearOfPlan> DeletePlan(int planId);
|
||||
|
||||
ServiceResponse<YearOfPlan> UpdatePlan(YearOfPlan plan);
|
||||
|
||||
ServiceResponse<YearOfPlan> UpdatePlan(YearOfPlan plan,List<ValidMonth> months);
|
||||
|
||||
|
||||
int GetRequestCollegeCount(int plandId, int unitId);
|
||||
|
||||
List<ValidMonth> GetValidMonthsOfPlan(int planId);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
using BlazorApp.DataLayer.Entities.General;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BlazorApp.Core.Services.Interface
|
||||
{
|
||||
public interface IDutyStatusService:IGenericRepositoryModern<General_DutyStatus>
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
using Microsoft.AspNetCore.Components.Forms;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BlazorApp.Core.Services.Interface
|
||||
{
|
||||
public interface IGenericRepositoryModern<TEntity> where TEntity : class
|
||||
{
|
||||
DbSet<TEntity> Entities { get; }
|
||||
IQueryable<TEntity> Table { get; }
|
||||
IQueryable<TEntity> TableNoTracking { get; }
|
||||
Task<ServiceResponse<bool>> SaveChangeAsync();
|
||||
void SaveChange();
|
||||
ServiceResponse<TEntity> Add(TEntity entity, bool saveNow = true);
|
||||
Task<ServiceResponse<TEntity>> AddAsync(TEntity entity, CancellationToken cancellationToken, bool saveNow = true);
|
||||
Task<ServiceResponse<IEnumerable<TEntity>>> AddRange(IEnumerable<TEntity> entities, bool saveNow = true);
|
||||
Task<ServiceResponse<IEnumerable<TEntity>>> AddRangeAsync(IEnumerable<TEntity> entities, CancellationToken cancellationToken, bool saveNow = true);
|
||||
void Attach(TEntity entity);
|
||||
ServiceResponse<TEntity> Delete(TEntity entity, bool saveNow = true);
|
||||
Task<ServiceResponse<TEntity>> DeleteAsync(TEntity entity, CancellationToken cancellationToken, bool saveNow = true);
|
||||
void DeleteRange(IEnumerable<TEntity> entities, bool saveNow = true);
|
||||
Task<ServiceResponse<IEnumerable<TEntity>>> DeleteRangeAsync(IEnumerable<TEntity> entities, CancellationToken cancellationToken, bool saveNow = true);
|
||||
void Detach(TEntity entity);
|
||||
TEntity GetById(params object[] ids);
|
||||
Task<ServiceResponse<TEntity>> GetByIdAsync(CancellationToken cancellationToken, params object[] ids);
|
||||
void LoadCollection<TProperty>(TEntity entity, Expression<Func<TEntity, IEnumerable<TProperty>>> collectionProperty) where TProperty : class;
|
||||
Task LoadCollectionAsync<TProperty>(TEntity entity, Expression<Func<TEntity, IEnumerable<TProperty>>> collectionProperty, CancellationToken cancellationToken) where TProperty : class;
|
||||
void LoadReference<TProperty>(TEntity entity, Expression<Func<TEntity, TProperty>> referenceProperty) where TProperty : class;
|
||||
Task LoadReferenceAsync<TProperty>(TEntity entity, Expression<Func<TEntity, TProperty>> referenceProperty, CancellationToken cancellationToken) where TProperty : class;
|
||||
ServiceResponse<TEntity> Update(TEntity entity, bool saveNow = true);
|
||||
Task<ServiceResponse<TEntity>> UpdateAsync(TEntity entity, CancellationToken cancellationToken, bool saveNow = true);
|
||||
void UpdateRange(IEnumerable<TEntity> entities, bool saveNow = true);
|
||||
Task<ServiceResponse<IEnumerable<TEntity>>> UpdateRangeAsync(IEnumerable<TEntity> entities, CancellationToken cancellationToken, bool saveNow = true);
|
||||
|
||||
Task<string?> SaveFileAsync(string path, InputFileChangeEventArgs file);
|
||||
|
||||
bool SaveFile(string path,InputFileChangeEventArgs file);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
using BlazorApp.DataLayer.Entities.TalentSearchs;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BlazorApp.Core.Services.Interface
|
||||
{
|
||||
public interface IPersonnelServiceTwo:IGenericRepositoryModern<Personnel>
|
||||
{
|
||||
Personnel GetLogin(string userName,string password);
|
||||
}
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
using BlazorApp.Core.Services.Interface;
|
||||
using BlazorApp.DataLayer.Entities.TalentSearchs;
|
||||
using Microsoft.AspNetCore.Components.Forms;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BlazorApp.Core.Services.Interface
|
||||
{
|
||||
public interface ITalentFrm_IndividualProfileService:IGenericRepositoryModern<TalentFrm_IndividualProfile>
|
||||
{
|
||||
Task<ServiceResponse<string>> AddAvatarProfile(InputFileChangeEventArgs file);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
using BlazorApp.DataLayer.Entities.Users;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BlazorApp.Core.Services
|
||||
{
|
||||
public partial class UserService:IUserService
|
||||
{
|
||||
public List<MarriageOfUser> GetAllMarriage()
|
||||
{
|
||||
return _context.MarriageOfUsers.ToList();
|
||||
}
|
||||
|
||||
public ServiceResponse<MarriageOfUser> CreateMarriage(MarriageOfUser marriage)
|
||||
{
|
||||
var item = new ServiceResponse<MarriageOfUser>();
|
||||
try
|
||||
{
|
||||
_context.MarriageOfUsers.Add(marriage);
|
||||
_context.SaveChanges();
|
||||
item.SetData(marriage);
|
||||
item.SetStatus(ResultStatus.Success);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
item.SetException(ex);
|
||||
item.SetStatus(ResultStatus.Error);
|
||||
item.SetData(marriage);
|
||||
}
|
||||
return item;
|
||||
}
|
||||
|
||||
public ServiceResponse<MarriageOfUser> UpdateMarriage(MarriageOfUser marriage)
|
||||
{
|
||||
var item = new ServiceResponse<MarriageOfUser>();
|
||||
try
|
||||
{
|
||||
_context.MarriageOfUsers.Update(marriage);
|
||||
_context.SaveChanges();
|
||||
item.SetData(marriage);
|
||||
item.SetStatus(ResultStatus.Success);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
item.SetException(ex);
|
||||
item.SetStatus(ResultStatus.Error);
|
||||
item.SetData(marriage);
|
||||
}
|
||||
return item;
|
||||
}
|
||||
|
||||
public ServiceResponse<MarriageOfUser> DeleteMarriage(MarriageOfUser marriage)
|
||||
{
|
||||
var item = new ServiceResponse<MarriageOfUser>();
|
||||
try
|
||||
{
|
||||
_context.MarriageOfUsers.Remove(marriage);
|
||||
_context.SaveChanges();
|
||||
item.SetData(marriage);
|
||||
item.SetStatus(ResultStatus.Success);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
item.SetException(ex);
|
||||
item.SetStatus(ResultStatus.Error);
|
||||
item.SetData(marriage);
|
||||
}
|
||||
return item;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
using BlazorApp.DataLayer.Entities.Mission;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using BlazorApp.DataLayer.Context;
|
||||
|
||||
namespace BlazorApp.Core.Services
|
||||
{
|
||||
public class MissionService : IMissionService
|
||||
{
|
||||
private BPOB_Context _context;
|
||||
public MissionService(BPOB_Context context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
public ServiceResponse<Mission> CreateMission(Mission mission)
|
||||
{
|
||||
|
||||
var item = new ServiceResponse<Mission>();
|
||||
try
|
||||
{
|
||||
if(_context.Missions.Where(m => m.Id == mission.Id).Any())
|
||||
{
|
||||
item.Status = ResultStatus.ConflictIdMission;
|
||||
item.SetData(mission);
|
||||
item.SetStatus(ResultStatus.ConflictIdMission);
|
||||
return item;
|
||||
}
|
||||
_context.Missions.Add(mission);
|
||||
_context.SaveChanges();
|
||||
item.SetData(mission);
|
||||
item.SetStatus(ResultStatus.Success);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
item.SetData(mission);
|
||||
item.SetException(ex);
|
||||
item.SetStatus(ResultStatus.Error);
|
||||
}
|
||||
return item;
|
||||
}
|
||||
|
||||
public ServiceResponse<Mission> DeleteMission(Mission mission)
|
||||
{
|
||||
var item = new ServiceResponse<Mission>();
|
||||
try
|
||||
{
|
||||
_context.Missions.Remove(mission);
|
||||
_context.SaveChanges();
|
||||
item.SetData(mission);
|
||||
item.SetStatus(ResultStatus.Success);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
item.SetException(ex);
|
||||
item.SetData(mission);
|
||||
item.SetStatus(ResultStatus.Error);
|
||||
|
||||
}
|
||||
return item;
|
||||
}
|
||||
|
||||
public List<Mission> GetAllMission()
|
||||
{
|
||||
return _context.Missions.ToList();
|
||||
}
|
||||
|
||||
public ServiceResponse<Mission> UpdateMission(Mission mission)
|
||||
{
|
||||
var item = new ServiceResponse<Mission>();
|
||||
try
|
||||
{
|
||||
|
||||
if (_context.Missions.Where(m => m.Id == mission.Id && m.MissionId != mission.MissionId).Any())
|
||||
{
|
||||
//item.SetData(mission);
|
||||
item.SetStatus(ResultStatus.ConflictIdMission);
|
||||
return item;
|
||||
}
|
||||
|
||||
_context.Missions.Update(mission);
|
||||
_context.SaveChanges();
|
||||
item.SetData(mission);
|
||||
item.SetStatus(ResultStatus.Success);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
item.SetException(ex);
|
||||
item.SetData(mission);
|
||||
item.Status = ResultStatus.Error;
|
||||
|
||||
}
|
||||
return item;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
using BlazorApp.Core.Services.Interface;
|
||||
using BlazorApp.DataLayer.Context;
|
||||
using BlazorApp.DataLayer.Entities.General;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BlazorApp.Core.Services.Modern.General
|
||||
{
|
||||
public class DutyStatusService : GenericRepositoryModern<General_DutyStatus>, IDutyStatusService
|
||||
{
|
||||
public DutyStatusService(BPOB_Context dbContext) : base(dbContext)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,349 @@
|
||||
using BlazorApp.Core.Services.Interface;
|
||||
using BlazorApp.DataLayer.Context;
|
||||
using Microsoft.AspNetCore.Components.Forms;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using static Microsoft.AspNetCore.Hosting.Internal.HostingApplication;
|
||||
|
||||
namespace BlazorApp.Core.Services.Modern
|
||||
{
|
||||
public class GenericRepositoryModern<TEntity> :IGenericRepositoryModern<TEntity>,IDisposable where TEntity : class
|
||||
{
|
||||
protected readonly BPOB_Context DbContext;
|
||||
public DbSet<TEntity> Entities { get; }
|
||||
public virtual IQueryable<TEntity> Table => Entities;
|
||||
public virtual IQueryable<TEntity> TableNoTracking => Entities.AsNoTracking();
|
||||
|
||||
|
||||
public GenericRepositoryModern(BPOB_Context dbContext)
|
||||
{
|
||||
DbContext = dbContext;
|
||||
Entities = DbContext.Set<TEntity>(); // City => Cities
|
||||
}
|
||||
|
||||
#region Async Method
|
||||
public virtual async Task<ServiceResponse<TEntity>> GetByIdAsync(CancellationToken cancellationToken, params object[] ids)
|
||||
{
|
||||
try
|
||||
{
|
||||
return await Entities.FindAsync(ids, cancellationToken).AsTask();
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
return new ServiceResponse<TEntity>() { Data = null, Status = ResultStatus.Error, Message = "خطایی در سرور رخ داد", ErrorException = ex };
|
||||
}
|
||||
}
|
||||
|
||||
public virtual async Task<ServiceResponse<TEntity>> AddAsync(TEntity entity, CancellationToken cancellationToken, bool saveNow = true)
|
||||
{
|
||||
|
||||
try
|
||||
{
|
||||
var entityFull = await DbContext.AddAsync(entity, cancellationToken).ConfigureAwait(false);
|
||||
if (saveNow)
|
||||
{
|
||||
await DbContext.SaveChangesAsync(cancellationToken).ConfigureAwait(false);
|
||||
entityFull.State = EntityState.Detached;
|
||||
}
|
||||
return entityFull.Entity;
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ServiceResponse<TEntity>() { Data = null, Status = ResultStatus.Error, Message = "خطایی در سرور رخ داد", ErrorException = ex };
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public virtual async Task<ServiceResponse<IEnumerable<TEntity>>> AddRangeAsync(IEnumerable<TEntity> entities, CancellationToken cancellationToken, bool saveNow = true)
|
||||
{
|
||||
try
|
||||
{
|
||||
await Entities.AddRangeAsync(entities, cancellationToken).ConfigureAwait(false);
|
||||
if (saveNow)
|
||||
await DbContext.SaveChangesAsync(cancellationToken).ConfigureAwait(false);
|
||||
return new ServiceResponse<IEnumerable<TEntity>>() { Data = entities, Status = ResultStatus.Success, Message = "با موفقیت انجام شد" }; ;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ServiceResponse<IEnumerable<TEntity>>() { Data = null, Status = ResultStatus.Error, Message = "خطایی در سرور رخ داد", ErrorException = ex };
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public virtual async Task<ServiceResponse<TEntity>> UpdateAsync(TEntity entity, CancellationToken cancellationToken, bool saveNow = true)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
var EntityState = Entities.Update(entity);
|
||||
if (saveNow)
|
||||
{
|
||||
await DbContext.SaveChangesAsync(cancellationToken);
|
||||
EntityState.State = Microsoft.EntityFrameworkCore.EntityState.Detached;
|
||||
}
|
||||
return entity;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ServiceResponse<TEntity>() { Data = null, Status = ResultStatus.Error, Message = "خطایی در سرور رخ داد", ErrorException = ex };
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public virtual async Task<ServiceResponse<IEnumerable<TEntity>>> UpdateRangeAsync(IEnumerable<TEntity> entities, CancellationToken cancellationToken, bool saveNow = true)
|
||||
{
|
||||
|
||||
try
|
||||
{
|
||||
Entities.UpdateRange(entities);
|
||||
if (saveNow)
|
||||
await DbContext.SaveChangesAsync(cancellationToken);
|
||||
|
||||
return new ServiceResponse<IEnumerable<TEntity>>() { Data = entities, Status = ResultStatus.Success, Message = "با موفقیت انجام شد" }; ;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
|
||||
return new ServiceResponse<IEnumerable<TEntity>>() { Data = null, Status = ResultStatus.Error, Message = "خطایی در سرور رخ داد", ErrorException = ex };
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public virtual async Task<ServiceResponse<TEntity>> DeleteAsync(TEntity entity, CancellationToken cancellationToken, bool saveNow = true)
|
||||
{
|
||||
try
|
||||
{
|
||||
Entities.Remove(entity);
|
||||
if (saveNow)
|
||||
await DbContext.SaveChangesAsync(cancellationToken);
|
||||
return entity;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ServiceResponse<TEntity>() { Data = null, Status = ResultStatus.Error, Message = "خطایی در سرور رخ داد", ErrorException = ex };
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public virtual async Task<ServiceResponse<IEnumerable<TEntity>>> DeleteRangeAsync(IEnumerable<TEntity> entities, CancellationToken cancellationToken, bool saveNow = true)
|
||||
{
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
Entities.RemoveRange(entities);
|
||||
if (saveNow)
|
||||
await DbContext.SaveChangesAsync(cancellationToken);
|
||||
return new ServiceResponse<IEnumerable<TEntity>>() { Data = entities, Status = ResultStatus.Success, Message = "با موفقیت انجام شد" }; ;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
|
||||
return new ServiceResponse<IEnumerable<TEntity>>() { Data = null, Status = ResultStatus.Error, Message = "خطایی در سرور رخ داد", ErrorException = ex };
|
||||
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Sync Methods
|
||||
public virtual TEntity GetById(params object[] ids)
|
||||
{
|
||||
return Entities.Find(ids);
|
||||
}
|
||||
|
||||
public virtual ServiceResponse<TEntity> Add(TEntity entity, bool saveNow = true)
|
||||
{
|
||||
|
||||
Entities.Add(entity);
|
||||
if (saveNow)
|
||||
DbContext.SaveChanges();
|
||||
return entity;
|
||||
}
|
||||
|
||||
public virtual async Task<ServiceResponse<IEnumerable<TEntity>>> AddRange(IEnumerable<TEntity> entities, bool saveNow = true)
|
||||
{
|
||||
|
||||
Entities.AddRange(entities);
|
||||
if (saveNow)
|
||||
DbContext.SaveChanges();
|
||||
return entities.ToList();
|
||||
}
|
||||
|
||||
public virtual ServiceResponse<TEntity> Update(TEntity entity, bool saveNow = true)
|
||||
{
|
||||
|
||||
Entities.Update(entity);
|
||||
DbContext.SaveChanges();
|
||||
return entity;
|
||||
}
|
||||
|
||||
public virtual void UpdateRange(IEnumerable<TEntity> entities, bool saveNow = true)
|
||||
{
|
||||
|
||||
Entities.UpdateRange(entities);
|
||||
if (saveNow)
|
||||
DbContext.SaveChanges();
|
||||
}
|
||||
|
||||
public virtual ServiceResponse<TEntity> Delete(TEntity entity, bool saveNow = true)
|
||||
{
|
||||
var save = entity;
|
||||
Entities.Remove(entity);
|
||||
if (saveNow)
|
||||
DbContext.SaveChanges();
|
||||
return save;
|
||||
}
|
||||
|
||||
public virtual void DeleteRange(IEnumerable<TEntity> entities, bool saveNow = true)
|
||||
{
|
||||
|
||||
Entities.RemoveRange(entities);
|
||||
if (saveNow)
|
||||
DbContext.SaveChanges();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Attach & Detach
|
||||
public virtual void Detach(TEntity entity)
|
||||
{
|
||||
|
||||
var entry = DbContext.Entry(entity);
|
||||
if (entry != null)
|
||||
entry.State = EntityState.Detached;
|
||||
}
|
||||
|
||||
public virtual void Attach(TEntity entity)
|
||||
{
|
||||
|
||||
if (DbContext.Entry(entity).State == EntityState.Detached)
|
||||
Entities.Attach(entity);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Explicit Loading
|
||||
public virtual async Task LoadCollectionAsync<TProperty>(TEntity entity, Expression<Func<TEntity, IEnumerable<TProperty>>> collectionProperty, CancellationToken cancellationToken)
|
||||
where TProperty : class
|
||||
{
|
||||
Attach(entity);
|
||||
|
||||
var collection = DbContext.Entry(entity).Collection(collectionProperty);
|
||||
if (!collection.IsLoaded)
|
||||
await collection.LoadAsync(cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
public virtual void LoadCollection<TProperty>(TEntity entity, Expression<Func<TEntity, IEnumerable<TProperty>>> collectionProperty)
|
||||
where TProperty : class
|
||||
{
|
||||
Attach(entity);
|
||||
var collection = DbContext.Entry(entity).Collection(collectionProperty);
|
||||
if (!collection.IsLoaded)
|
||||
collection.Load();
|
||||
}
|
||||
|
||||
public virtual async Task LoadReferenceAsync<TProperty>(TEntity entity, Expression<Func<TEntity, TProperty>> referenceProperty, CancellationToken cancellationToken)
|
||||
where TProperty : class
|
||||
{
|
||||
Attach(entity);
|
||||
var reference = DbContext.Entry(entity).Reference(referenceProperty);
|
||||
if (!reference.IsLoaded)
|
||||
await reference.LoadAsync(cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
public virtual void LoadReference<TProperty>(TEntity entity, Expression<Func<TEntity, TProperty>> referenceProperty)
|
||||
where TProperty : class
|
||||
{
|
||||
Attach(entity);
|
||||
var reference = DbContext.Entry(entity).Reference(referenceProperty);
|
||||
if (!reference.IsLoaded)
|
||||
reference.Load();
|
||||
}
|
||||
|
||||
public void SaveChange()
|
||||
{
|
||||
DbContext.SaveChanges();
|
||||
}
|
||||
|
||||
public async Task<ServiceResponse<bool>> SaveChangeAsync()
|
||||
{
|
||||
try
|
||||
{
|
||||
await DbContext.SaveChangesAsync();
|
||||
return new ServiceResponse<bool>() { Data = true, Status = ResultStatus.Success, Message = "با موفقیت انجام شد" }; ;
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
return new ServiceResponse<bool>() { Data = false, Status = ResultStatus.Error, Message = "خطایی در سرور رخ داد", ErrorException = ex };
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public bool IsAlready(string property, string value, bool throwEx = false)
|
||||
{
|
||||
var prop = typeof(TEntity).GetProperty(property);
|
||||
|
||||
foreach (var per in TableNoTracking.ToList())
|
||||
{
|
||||
if (prop.GetValue(per).ToString() == value)
|
||||
{
|
||||
if (throwEx)
|
||||
{
|
||||
throw new Exception(message: "تکراری می باشد");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
#endregion
|
||||
public void Dispose()
|
||||
{
|
||||
DbContext.Dispose();
|
||||
}
|
||||
|
||||
public async Task<string?> SaveFileAsync(string path, InputFileChangeEventArgs file)
|
||||
{
|
||||
try
|
||||
{
|
||||
string ex = Path.GetExtension(file.File.Name).ToLower();
|
||||
string name = NameGenerator.GenerateUniqCode() + ex;
|
||||
string newPath = Path.Combine("wwwroot", "talent-search", path, name);
|
||||
await using FileStream fs = new(newPath, FileMode.Create);
|
||||
await file.File.OpenReadStream().CopyToAsync(fs);
|
||||
return name;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public bool SaveFile(string path, InputFileChangeEventArgs file)
|
||||
{
|
||||
try
|
||||
{
|
||||
return true;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
using BlazorApp.Core.Security;
|
||||
using BlazorApp.Core.Services.Interface;
|
||||
using BlazorApp.Core.Services.Modern;
|
||||
using BlazorApp.DataLayer.Context;
|
||||
using BlazorApp.DataLayer.Entities.TalentSearchs;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BlazorApp.Core.Services
|
||||
{
|
||||
public class PersonnelServiceTwo : GenericRepositoryModern<Personnel>, IPersonnelServiceTwo
|
||||
{
|
||||
public PersonnelServiceTwo(BPOB_Context dbContext) : base(dbContext)
|
||||
{
|
||||
}
|
||||
|
||||
public override ServiceResponse<Personnel> Update(Personnel entity, bool saveNow = true)
|
||||
{
|
||||
var oldPersonnel = TableNoTracking.Where(p => p.PersonnelId == entity.PersonnelId).SingleOrDefault();
|
||||
|
||||
if (oldPersonnel.UserName != entity.UserName)
|
||||
{
|
||||
if (IsAlready(nameof(entity.UserName), entity.UserName))
|
||||
{
|
||||
return new ServiceResponse<Personnel>()
|
||||
{
|
||||
Message = "نام کاربری تکراری می باشد",
|
||||
Status = ResultStatus.Error,
|
||||
Data = entity
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return base.Update(entity, saveNow);
|
||||
}
|
||||
|
||||
public override ServiceResponse<Personnel> Add(Personnel entity, bool saveNow = true)
|
||||
{
|
||||
if (IsAlready(nameof(entity.UserName), entity.UserName))
|
||||
{
|
||||
return new ServiceResponse<Personnel>()
|
||||
{
|
||||
Message = "نام کاربری تکراری می باشد",
|
||||
Status = ResultStatus.Error,
|
||||
Data = entity
|
||||
};
|
||||
}
|
||||
|
||||
entity.Password = PasswordHelper.EncodePasswordMd5(entity.Password);
|
||||
return base.Add(entity, saveNow);
|
||||
}
|
||||
|
||||
public Personnel GetLogin(string userName, string password)
|
||||
{
|
||||
string pass = PasswordHelper.EncodePasswordMd5(password);
|
||||
return Table.Where(p => p.UserName == userName && p.Password == pass).SingleOrDefault();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
using BlazorApp.Core.Services.Interface;
|
||||
using BlazorApp.DataLayer.Context;
|
||||
using BlazorApp.DataLayer.Entities.TalentSearchs;
|
||||
using Microsoft.AspNetCore.Components.Forms;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BlazorApp.Core.Services.Modern.TalentSearch
|
||||
{
|
||||
public class TalentFrm_IndividualService : GenericRepositoryModern<TalentFrm_IndividualProfile>, ITalentFrm_IndividualProfileService
|
||||
{
|
||||
public TalentFrm_IndividualService(BPOB_Context context) : base(context)
|
||||
{
|
||||
}
|
||||
|
||||
public async Task<ServiceResponse<string>> AddAvatarProfile(InputFileChangeEventArgs file)
|
||||
{
|
||||
string fileName = "Default.png";
|
||||
string ex = Path.GetExtension(file.File.Name).ToLower();
|
||||
if(ex != ".png" && ex != ".jpeg" && ex != ".gif" && ex != ".jpg")
|
||||
{
|
||||
return new ServiceResponse<string>() { Status = ResultStatus.InvalidFormat };
|
||||
}
|
||||
|
||||
string newName = NameGenerator.GenerateUniqCode() + ex;
|
||||
var path = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot", "talent-search", "personnel-pictures", newName);
|
||||
var setStatus = await Set(path, file);
|
||||
|
||||
return newName;
|
||||
}
|
||||
|
||||
private async Task<bool> Set(string path, InputFileChangeEventArgs e)
|
||||
{
|
||||
await using FileStream fs = new(path, FileMode.Create);
|
||||
await e.File.OpenReadStream().CopyToAsync(fs);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,227 @@
|
||||
using BlazorApp.DataLayer.Entities.OrganizationalUnits;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using BlazorApp.DataLayer.Context;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using BlazorApp.DataLayer.Entities.Colleges.Schedule;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
|
||||
namespace BlazorApp.Core.Services
|
||||
{
|
||||
public partial class OU_Service : IOU_Service
|
||||
{
|
||||
private BPOB_Context _context;
|
||||
public OU_Service(BPOB_Context context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
public ServiceResponse<OrganizationalUnit> CreateOU(OrganizationalUnit ou)
|
||||
{
|
||||
var item = new ServiceResponse<OrganizationalUnit>();
|
||||
try
|
||||
{
|
||||
_context.OrganizationalUnits.Add(ou);
|
||||
_context.SaveChanges();
|
||||
item.SetData(ou);
|
||||
item.SetStatus(ResultStatus.Success);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
item.SetException(ex);
|
||||
item.SetData(ou);
|
||||
item.SetStatus(ResultStatus.Error);
|
||||
}
|
||||
return item;
|
||||
}
|
||||
|
||||
public ServiceResponse<OrganizationalUnit> DeleteOU(OrganizationalUnit ou)
|
||||
{
|
||||
var item = new ServiceResponse<OrganizationalUnit>();
|
||||
try
|
||||
{
|
||||
_context.OrganizationalUnits.Remove(ou);
|
||||
_context.SaveChanges();
|
||||
item.SetData(ou);
|
||||
item.SetStatus(ResultStatus.Success);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
item.SetException(ex);
|
||||
item.SetData(ou);
|
||||
item.SetStatus(ResultStatus.Error);
|
||||
}
|
||||
return item;
|
||||
}
|
||||
|
||||
public List<OrganizationalUnit> GetAllOUs()
|
||||
{
|
||||
return _context.OrganizationalUnits.ToList();
|
||||
}
|
||||
|
||||
public OrganizationalUnit GetOrganizationalUnit(int ouid)
|
||||
{
|
||||
return _context.OrganizationalUnits.Where(o => o.OU_Id == ouid).Include(or => or.ScheduleTitles).SingleOrDefault();
|
||||
|
||||
}
|
||||
|
||||
public ServiceResponse<OrganizationalUnit> UpdateOU(OrganizationalUnit ou)
|
||||
{
|
||||
var item = new ServiceResponse<OrganizationalUnit>();
|
||||
try
|
||||
{
|
||||
_context.OrganizationalUnits.Update(ou);
|
||||
_context.SaveChanges();
|
||||
item.SetData(ou);
|
||||
item.SetStatus(ResultStatus.Success);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
item.SetException(ex);
|
||||
item.SetData(ou);
|
||||
item.SetStatus(ResultStatus.Error);
|
||||
}
|
||||
return item;
|
||||
}
|
||||
|
||||
|
||||
public List<ScheduleOfOU> GetScheduleOfOus(int ouId, int planId)
|
||||
{
|
||||
return _context.SchedulesOf_OU.Where(s => s.OU_Id == ouId && s.YearId == planId)
|
||||
.Include(s => s.Guideline)
|
||||
.Include(s => s.Target)
|
||||
.Include(s => s.AppType)
|
||||
.Include(s => s.Level)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
|
||||
public float SumAmountOfMonth(ScheduleOfOU schedule)
|
||||
{
|
||||
float amount = 0;
|
||||
amount += schedule.Farvardin;
|
||||
amount += schedule.Ordibehesht;
|
||||
amount += schedule.Khordad;
|
||||
amount += schedule.Tir;
|
||||
amount += schedule.Mordad;
|
||||
amount += schedule.Shahrivar;
|
||||
amount += schedule.Mehr;
|
||||
amount += schedule.Aban;
|
||||
amount += schedule.Azar;
|
||||
amount += schedule.Dey;
|
||||
amount += schedule.Bahman;
|
||||
amount += schedule.Esfand;
|
||||
return amount;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public ServiceResponse<int> AllRequestCount(int ouId)
|
||||
{
|
||||
ServiceResponse<int> result = new ServiceResponse<int>();
|
||||
try
|
||||
{
|
||||
var r = _context.RequestsFromColleges.Where(r => r.Schedule.ScheduleText.OuId == ouId && r.AllocationAmount != 0 && r.RequestAmount != 0 && r.OU_Amount == 0 && r.ManagerAmount == 0).Count();
|
||||
//var r = _context.RequestsFromColleges.Where(r => r.Schedule.ScheduleText.OuId == ouId && r.CheckRequest() .Count();
|
||||
result.SetData(r);
|
||||
result.SetStatus(ResultStatus.Success);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
result.SetException(ex);
|
||||
result.SetStatus(ResultStatus.Error);
|
||||
throw;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
public ServiceResponse<int> YearRequestCount(int ouId, int yearId)
|
||||
{
|
||||
ServiceResponse<int> result = new ServiceResponse<int>();
|
||||
|
||||
try
|
||||
{
|
||||
int number = _context.RequestsFromColleges.Where(r =>
|
||||
r.Schedule.ScheduleText.OuId == ouId &&
|
||||
r.Schedule.YearId == yearId &&
|
||||
r.AllocationAmount != 0 &&
|
||||
r.RequestAmount != 0 &&
|
||||
r.OU_Amount == 0 &&
|
||||
r.ManagerAmount ==0
|
||||
).Count();
|
||||
|
||||
result.SetData(number);
|
||||
result.SetStatus(ResultStatus.Success);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
result.SetStatus(ResultStatus.Error);
|
||||
result.SetException(ex);
|
||||
throw;
|
||||
}
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public ServiceResponse<int> MonthRequestCount(int ouId, int yearId, int monthId)
|
||||
{
|
||||
ServiceResponse<int> result = new ServiceResponse<int>();
|
||||
try
|
||||
{
|
||||
int number = _context.RequestsFromColleges.Where(r =>
|
||||
r.Schedule.ScheduleText.OuId == ouId &&
|
||||
r.Schedule.YearId == yearId &&
|
||||
r.MonthId == monthId &&
|
||||
r.AllocationAmount != 0 &&
|
||||
r.RequestAmount != 0 &&
|
||||
r.OU_Amount == 0 &&
|
||||
r.ManagerAmount == 0
|
||||
).Count();
|
||||
|
||||
result.SetData(number);
|
||||
result.SetStatus(ResultStatus.Success);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
result.SetStatus(ResultStatus.Error);
|
||||
result.SetException(ex);
|
||||
throw;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public ServiceResponse<int> CollegeRequestCount(int ouId, int yearId, int monthId, int collegeId)
|
||||
{
|
||||
ServiceResponse<int> result = new ServiceResponse<int>();
|
||||
|
||||
try
|
||||
{
|
||||
int number = _context.RequestsFromColleges.Where(r =>
|
||||
r.Schedule.ScheduleText.OuId == ouId &&
|
||||
r.Schedule.YearId == yearId &&
|
||||
r.MonthId == monthId &&
|
||||
r.Schedule.CollegeId == collegeId &&
|
||||
r.AllocationAmount != 0 &&
|
||||
r.RequestAmount != 0 &&
|
||||
r.OU_Amount == 0 &&
|
||||
r.ManagerAmount == 0
|
||||
).Count();
|
||||
result.SetData(number);
|
||||
result.SetStatus(ResultStatus.Success);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
result.SetStatus(ResultStatus.Error);
|
||||
result.SetException(ex);
|
||||
throw;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,291 @@
|
||||
using BlazorApp.DataLayer.Context;
|
||||
using BlazorApp.DataLayer.Entities.Permissions;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BlazorApp.Core.Services
|
||||
{
|
||||
public class PermissionService : IPermissionService
|
||||
{
|
||||
private BPOB_Context _context;
|
||||
private IUserService _userService;
|
||||
public PermissionService(BPOB_Context context,IUserService userService)
|
||||
{
|
||||
_context = context;
|
||||
_userService = userService;
|
||||
}
|
||||
|
||||
public ServiceResponse<Role> CreateRole(Role role)
|
||||
{
|
||||
var item = new ServiceResponse<Role>();
|
||||
try
|
||||
{
|
||||
_context.Roles.Add(role);
|
||||
_context.SaveChanges();
|
||||
item.SetData(role);
|
||||
item.SetStatus(ResultStatus.Success);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
item.SetException(ex);
|
||||
item.SetData(role);
|
||||
item.SetStatus(ResultStatus.Error);
|
||||
}
|
||||
return item;
|
||||
}
|
||||
|
||||
public ServiceResponse<Role> DeleteRole(Role role)
|
||||
{
|
||||
var item = new ServiceResponse<Role>();
|
||||
try
|
||||
{
|
||||
_context.Roles.Remove(role);
|
||||
_context.SaveChanges();
|
||||
item.SetData(role);
|
||||
item.SetStatus(ResultStatus.Success);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
item.SetException(ex);
|
||||
item.SetData(role);
|
||||
item.SetStatus(ResultStatus.Error);
|
||||
}
|
||||
return item;
|
||||
}
|
||||
|
||||
public List<Permission> GetAllPermissions()
|
||||
{
|
||||
return _context.Permissions.ToList();
|
||||
}
|
||||
|
||||
public List<Role> GetAllRoles()
|
||||
{
|
||||
return _context.Roles.ToList();
|
||||
}
|
||||
|
||||
public List<Permission> GetPermissionsOfRole(int roleId)
|
||||
{
|
||||
return _context.RolePermissions.Where(r => r.RoleId == roleId).Select(r => r.Permission).ToList();
|
||||
}
|
||||
|
||||
public List<Role> GetRolesOfUser(int userId)
|
||||
{
|
||||
return _context.UserRoles.Where(u => u.UserId == userId).Select(u => u.Role).ToList();
|
||||
}
|
||||
|
||||
public ServiceResponse<bool> UpdatePermissionsOfRole(List<int> permissions, int roleId)
|
||||
{
|
||||
var item = new ServiceResponse<bool>();
|
||||
try
|
||||
{
|
||||
List<RolePermission> oldP = _context.RolePermissions.Where(r => r.RoleId == roleId).ToList();
|
||||
foreach (var r in oldP)
|
||||
{
|
||||
_context.RolePermissions.Remove(r);
|
||||
}
|
||||
|
||||
foreach (var r in permissions)
|
||||
{
|
||||
RolePermission rolePermission = new RolePermission()
|
||||
{
|
||||
RoleId = roleId,
|
||||
PermissionId = r
|
||||
};
|
||||
_context.RolePermissions.Add(rolePermission);
|
||||
}
|
||||
_context.SaveChanges();
|
||||
item.SetData(true);
|
||||
item.SetStatus(ResultStatus.Success);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
item.SetException(ex);
|
||||
item.SetData(false);
|
||||
item.SetStatus(ResultStatus.Error);
|
||||
}
|
||||
return item;
|
||||
}
|
||||
|
||||
public ServiceResponse<Role> UpdateRole(Role role)
|
||||
{
|
||||
var item = new ServiceResponse<Role>();
|
||||
try
|
||||
{
|
||||
_context.Roles.Update(role);
|
||||
_context.SaveChanges();
|
||||
item.SetData(role);
|
||||
item.SetStatus(ResultStatus.Success);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
item.SetException(ex);
|
||||
item.SetData(role);
|
||||
item.SetStatus(ResultStatus.Error);
|
||||
}
|
||||
return item;
|
||||
}
|
||||
|
||||
public ServiceResponse<bool> UpdateRolesOfUser(List<Role> roles, int userId)
|
||||
{
|
||||
var item = new ServiceResponse<bool>();
|
||||
try
|
||||
{
|
||||
var oldRoles = _context.UserRoles.Where(u => u.UserId == userId).ToList();
|
||||
foreach(var r in oldRoles)
|
||||
{
|
||||
_context.UserRoles.Remove(r);
|
||||
}
|
||||
|
||||
foreach(var r in roles)
|
||||
{
|
||||
UserRole userRole = new UserRole()
|
||||
{
|
||||
RoleId = r.RoleId,
|
||||
UserId = userId
|
||||
};
|
||||
_context.UserRoles.Add(userRole);
|
||||
}
|
||||
_context.SaveChanges();
|
||||
item.SetData(true);
|
||||
item.SetStatus(ResultStatus.Success);
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
item.SetException(ex);
|
||||
item.SetData(false);
|
||||
item.SetStatus(ResultStatus.Error);
|
||||
}
|
||||
return item;
|
||||
}
|
||||
public ServiceResponse<bool> UpdateCollegePermissionsOfRole(List<int> collegePermissions, int roleId)
|
||||
{
|
||||
var item = new ServiceResponse<bool>();
|
||||
try
|
||||
{
|
||||
var oldPermission = _context.CollegePermissions.Where(u => u.RoleId == roleId).ToList();
|
||||
foreach(var p in oldPermission)
|
||||
{
|
||||
_context.CollegePermissions.Remove(p);
|
||||
}
|
||||
|
||||
foreach(var p in collegePermissions)
|
||||
{
|
||||
CollegePermission cp = new CollegePermission() {
|
||||
CollegeId = p,
|
||||
RoleId = roleId
|
||||
};
|
||||
_context.CollegePermissions.Add(cp);
|
||||
}
|
||||
_context.SaveChanges();
|
||||
item.SetData(true);
|
||||
item.SetStatus(ResultStatus.Success);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
item.SetData(false);
|
||||
item.SetStatus(ResultStatus.Error);
|
||||
item.SetException(ex);
|
||||
}
|
||||
return item;
|
||||
}
|
||||
|
||||
public ServiceResponse<bool> UpdateOuPermissionsOfRole(List<int> ouPermissions, int roleId)
|
||||
{
|
||||
var item = new ServiceResponse<bool>();
|
||||
try
|
||||
{
|
||||
var oldPermissions = _context.OuPermissions.Where(u => u.RoleId == roleId).ToList();
|
||||
foreach(var p in oldPermissions)
|
||||
{
|
||||
_context.OuPermissions.Remove(p);
|
||||
}
|
||||
foreach(var p in ouPermissions)
|
||||
{
|
||||
OuPermission op = new OuPermission() {OU_Id = p,RoleId = roleId };
|
||||
_context.OuPermissions.Add(op);
|
||||
}
|
||||
_context.SaveChanges();
|
||||
item.SetData(true);
|
||||
item.SetStatus(ResultStatus.Success);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
item.SetData(false);
|
||||
item.SetStatus(ResultStatus.Error);
|
||||
item.SetException(ex);
|
||||
}
|
||||
return item;
|
||||
}
|
||||
|
||||
public List<CollegePermission> GetCollegePermissionsOfRole(int roleId)
|
||||
{
|
||||
return _context.CollegePermissions.Where(u => u.RoleId == roleId).ToList();
|
||||
}
|
||||
|
||||
public List<OuPermission> GetOuPermissionsOfRole(int roleId)
|
||||
{
|
||||
return _context.OuPermissions.Where(o => o.RoleId == roleId).ToList();
|
||||
}
|
||||
|
||||
public bool CheckRole(int userId, int roleId)
|
||||
{
|
||||
if (_context.UserRoles.Any(u => u.UserId == userId && u.RoleId == roleId))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public Role GetRoleByRoleId(int roleId)
|
||||
{
|
||||
return _context.Roles.Find(roleId);
|
||||
}
|
||||
|
||||
public bool ChekPermission(string userName, int permissionId)
|
||||
{
|
||||
int userId = _userService.GetUserByUserName(userName).UserId;
|
||||
|
||||
List<int> userRoles = _context.UserRoles.Where(ur => ur.UserId == userId).Select(ur => ur.RoleId).ToList();
|
||||
|
||||
List<int> rolePermissions = _context.RolePermissions.Where(rp => rp.PermissionId == permissionId).Select(rp => rp.RoleId).ToList();
|
||||
|
||||
return rolePermissions.Any(rp => userRoles.Contains(rp));
|
||||
}
|
||||
|
||||
public List<CollegePermission> GetCollegePermissionOfRole(int roleId)
|
||||
{
|
||||
return _context.CollegePermissions.Where(c => c.RoleId == roleId).Include(c => c.College).ToList();
|
||||
}
|
||||
|
||||
public List<OuPermission> GetOuPermissionOfRole(int roleId)
|
||||
{
|
||||
return _context.OuPermissions.Where(o => o.RoleId == roleId).Include(o => o.OraOrganizationalUnit).ToList();
|
||||
}
|
||||
|
||||
public bool CheckOuPermission(int roleId, int ouId)
|
||||
{
|
||||
return _context.OuPermissions.Any(p => p.RoleId == roleId && p.OU_Id == ouId);
|
||||
}
|
||||
public bool CheckCollegePermission(int roleId, int collegeId)
|
||||
{
|
||||
if (_context.CollegePermissions.Any(c => c.RoleId == roleId && c.CollegeId == collegeId))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
public bool CheckPermissionForRole(int roleId, int permissionId)
|
||||
{
|
||||
return _context.RolePermissions.Any(p => p.RoleId == roleId && p.PermissionId == permissionId);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,154 @@
|
||||
using AutoMapper;
|
||||
using BlazorApp.Core.DTOs;
|
||||
using BlazorApp.Core.Security;
|
||||
using BlazorApp.Core.Services;
|
||||
using BlazorApp.DataLayer.Context;
|
||||
using BlazorApp.DataLayer.Entities.TalentSearchs;
|
||||
using Microsoft.AspNetCore.Mvc.Internal;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Internal;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
using System.Net.Mime;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BlazorApp.Core
|
||||
{
|
||||
public class PersonnelService : IPersonnelService
|
||||
{
|
||||
private readonly BPOB_Context context;
|
||||
private readonly IMapper mapper;
|
||||
public PersonnelService(BPOB_Context context, IMapper mapper)
|
||||
{
|
||||
this.context = context;
|
||||
this.mapper = mapper;
|
||||
}
|
||||
|
||||
public ServiceResponse<Personnel> Create(Personnel item)
|
||||
{
|
||||
ServiceResponse<Personnel> result = new();
|
||||
try
|
||||
{
|
||||
|
||||
var s = TestAlready(nameof(item.UserName), item.UserName,true);
|
||||
var personnel = mapper.Map<Personnel>(item);
|
||||
personnel.Password = PasswordHelper.EncodePasswordMd5(personnel.Password);
|
||||
context.Personnels.Add(personnel);
|
||||
context.SaveChanges();
|
||||
result.SetData(personnel);
|
||||
result.SetStatus(ResultStatus.Success);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
result.SetStatus(ResultStatus.Error);
|
||||
result.SetException(ex);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public ServiceResponse<Personnel> Delete(Personnel item)
|
||||
{
|
||||
ServiceResponse<Personnel> result = new();
|
||||
try
|
||||
{
|
||||
context.Personnels.Remove(item);
|
||||
context.SaveChanges();
|
||||
result.SetStatus(true);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
result.SetStatus(false);
|
||||
result.SetException(ex);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public List<Personnel> GetAllItem(Expression<Func<Personnel, bool>>? expression = null)
|
||||
{
|
||||
IQueryable<Personnel> personnels = context.Personnels.Include(p => p.College).AsQueryable();
|
||||
|
||||
if (expression != null)
|
||||
{
|
||||
personnels = personnels.Where(expression.Compile()).AsQueryable();
|
||||
}
|
||||
|
||||
return personnels.ToList();
|
||||
}
|
||||
|
||||
public Personnel GetItem(int itemId)
|
||||
{
|
||||
return context.Personnels.Where(p => p.PersonnelId == itemId).SingleOrDefault();
|
||||
}
|
||||
|
||||
public ServiceResponse<Personnel> Update(Personnel item)
|
||||
{
|
||||
ServiceResponse<Personnel> result = new();
|
||||
try
|
||||
{
|
||||
var ss = context.Personnels.Where(p => p.PersonnelId == 2).SingleOrDefault();
|
||||
Personnel old = GetItem(item.PersonnelId);
|
||||
|
||||
if (old.UserName != item.UserName)
|
||||
{
|
||||
TestAlready(nameof(item.UserName), item.UserName, true);
|
||||
|
||||
}
|
||||
|
||||
old.PersonnelName = item.PersonnelName;
|
||||
old.PersonnelFamily = item.PersonnelFamily;
|
||||
old.CollegeId = item.CollegeId;
|
||||
old.NationalCode = item.NationalCode;
|
||||
old.PersonnelCode = item.PersonnelCode;
|
||||
old.UserName = item.UserName;
|
||||
|
||||
context.Personnels.Update(old);
|
||||
context.SaveChanges();
|
||||
|
||||
result.SetStatus(true);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
result.SetStatus(false);
|
||||
result.SetException(ex);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
bool TestAlready(string property, string value, bool throwEx = false)
|
||||
{
|
||||
var prop = typeof(Personnel).GetProperty(property);
|
||||
|
||||
foreach (var per in context.Personnels.ToList())
|
||||
{
|
||||
if (prop.GetValue(per).ToString() == value)
|
||||
{
|
||||
if(throwEx)
|
||||
{
|
||||
throw new Exception(message:"تکراری می باشد");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool AlreadyUserName(string userName)
|
||||
{
|
||||
if (context.Personnels.Any(p => p.UserName.ToLower() == userName.ToLower()))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
using BlazorApp.Core.DTOs;
|
||||
using BlazorApp.DataLayer.Entities.Users;
|
||||
using Microsoft.AspNetCore.Mvc.Internal;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BlazorApp.Core.Services
|
||||
{
|
||||
public partial class UserService:IUserService
|
||||
{
|
||||
public ServiceResponse<bool> UpdatePassword(UpdatePasswordViewModel userPassword)
|
||||
{
|
||||
ServiceResponse<bool> result = new ServiceResponse<bool>();
|
||||
try
|
||||
{
|
||||
User user = GetUserById(userPassword.UserId);
|
||||
if(user.Password == userPassword.OldPassword)
|
||||
{
|
||||
if(userPassword.Password == userPassword.RePassword)
|
||||
{
|
||||
user.Password = userPassword.Password;
|
||||
UpdateUser(user);
|
||||
result.SetData(true);
|
||||
result.SetStatus(ResultStatus.Success);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
result.SetData(false);
|
||||
result.SetStatus(ResultStatus.Error);
|
||||
result.SetMessage("رمز عبور فعلی صحیح نمیباشد");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
result.SetData(false);
|
||||
result.SetStatus(ResultStatus.Error);
|
||||
result.SetException(ex);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public ServiceResponse<bool> UpdateUserName(UpdateUserNameViewModel updateUserName)
|
||||
{
|
||||
ServiceResponse<bool> result = new ServiceResponse<bool>();
|
||||
try
|
||||
{
|
||||
User user = GetUserById(updateUserName.UserId) ;
|
||||
if(_context.Users.Where(u => u.UserName.ToLower() == updateUserName.NewUserName.ToLower()).Any())
|
||||
{
|
||||
result.SetData(false);
|
||||
result.SetStatus(ResultStatus.Error);
|
||||
result.SetMessage("نام کاربری وارد شده قبلا استفاده شده است");
|
||||
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
user.UserName = updateUserName.NewUserName;
|
||||
UpdateUser(user);
|
||||
result.SetData(true);
|
||||
result.SetStatus(ResultStatus.Success);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
result.SetData(false);
|
||||
result.SetStatus(ResultStatus.Error);
|
||||
result.SetException(ex);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,946 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml.Schema;
|
||||
using BlazorApp.Core.Convertors;
|
||||
using BlazorApp.Core.DTOs;
|
||||
using BlazorApp.DataLayer.Context;
|
||||
using BlazorApp.DataLayer.Entities;
|
||||
using BlazorApp.DataLayer.Entities.Colleges;
|
||||
using BlazorApp.DataLayer.Entities.Colleges.Schedule;
|
||||
using BlazorApp.DataLayer.Entities.OrganizationalUnits;
|
||||
using BlazorApp.DataLayer.Entities.Plans;
|
||||
using BlazorApp.DataLayer.Entities.Users;
|
||||
using BlazorApp.DataLayer.Migrations;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Query;
|
||||
using Microsoft.EntityFrameworkCore.Storage;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion.Internal;
|
||||
using Microsoft.IdentityModel.Tokens;
|
||||
using OfficeOpenXml;
|
||||
using OfficeOpenXml.FormulaParsing.Excel;
|
||||
|
||||
namespace BlazorApp.Core.Services
|
||||
{
|
||||
public class ReportService : IReportService
|
||||
{
|
||||
private BPOB_Context context;
|
||||
public ReportService(BPOB_Context context)
|
||||
{
|
||||
this.context = context;
|
||||
}
|
||||
public async Task<List<ReportUnitViewModel>> GetReportUnit(List<YearOfPlan> plans, List<Month> months)
|
||||
{
|
||||
|
||||
List<ReportUnitViewModel> lst = new List<ReportUnitViewModel>();
|
||||
|
||||
var Units = await context.OrganizationalUnits.ToListAsync();
|
||||
|
||||
foreach (var unit in Units)
|
||||
{
|
||||
ReportUnitViewModel report = new ReportUnitViewModel();
|
||||
report.UnitTitle = unit.OU_Title;
|
||||
|
||||
report.OuId = unit.OU_Id;
|
||||
|
||||
report.AllocationAmount = AllocationCollege(plans, months, unit.OU_Id) + AllocationOU(plans, months, unit.OU_Id);
|
||||
|
||||
report.RequestAmount = RequestCollege(plans, months, unit.OU_Id) + RequestOu(plans, months, unit.OU_Id);
|
||||
|
||||
|
||||
float ouRequest = context.RequestsFromUnits.Where(r => plans.Contains(r.Schedule.YearOfPlan) &&
|
||||
months.Contains(r.Month) && r.Schedule.ScheduleText.OuId == unit.OU_Id).Select(r => r.RequestAmount).Sum();
|
||||
|
||||
float collegeRequest = context.RequestsFromColleges
|
||||
.Where(r => plans.Contains(r.Schedule.YearOfPlan) &&
|
||||
months.Contains(r.Month) &&
|
||||
r.Schedule.ScheduleText.OuId == unit.OU_Id)
|
||||
.Select(r => r.OU_Amount)
|
||||
.Sum();
|
||||
|
||||
report.Ou_Amount = ouRequest + collegeRequest;
|
||||
report.ManagerAmount = ManagerCollege(plans, months, unit.OU_Id) + ManagerOu(plans, months, unit.OU_Id);
|
||||
|
||||
report.PaymentAmount = PaymentCollege(plans, months, unit.OU_Id) + PaymentOu(plans, months, unit.OU_Id);
|
||||
|
||||
lst.Add(report);
|
||||
}
|
||||
|
||||
return lst;
|
||||
|
||||
|
||||
}
|
||||
|
||||
float AllocationOU(List<YearOfPlan> plans, List<Month> months, int unitId)
|
||||
{
|
||||
var schedules = context.SchedulesOf_OU.Where(s => plans.Contains(s.YearOfPlan) && s.OU_Id == unitId).ToList();
|
||||
float amount = 0;
|
||||
foreach (var schedule in schedules)
|
||||
{
|
||||
foreach (var month in months)
|
||||
{
|
||||
amount += GetMonthAmountForScheduleOu(schedule, month.MonthId);
|
||||
}
|
||||
}
|
||||
|
||||
return amount;
|
||||
|
||||
}
|
||||
|
||||
float RequestOu(List<YearOfPlan> plans, List<Month> months, int unitId)
|
||||
{
|
||||
var requests = context.RequestsFromUnits.Where(r => r.Schedule.OU_Id == unitId && months.Contains(r.Month) && plans.Contains(r.Schedule.YearOfPlan)).ToList();
|
||||
|
||||
float amount = 0;
|
||||
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
amount = requests.Select(r => r.RequestAmount).Sum();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
return amount;
|
||||
}
|
||||
|
||||
float ManagerOu(List<YearOfPlan> plans, List<Month> months, int unitId)
|
||||
{
|
||||
var requests = context.RequestsFromUnits.Where(r => r.Schedule.OU_Id == unitId && months.Contains(r.Month) && plans.Contains(r.Schedule.YearOfPlan)).ToList();
|
||||
float amount = 0;
|
||||
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
amount = requests.Select(r => r.ManagerAmount).Sum();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
return amount;
|
||||
}
|
||||
|
||||
float PaymentOu(List<YearOfPlan> plans, List<Month> months, int unitId)
|
||||
{
|
||||
var requests = context.RequestsFromUnits.Where(r => r.Schedule.OU_Id == unitId && months.Contains(r.Month) && plans.Contains(r.Schedule.YearOfPlan)).ToList();
|
||||
float amount = 0;
|
||||
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
amount = requests.Select(r => r.PaymentAmount).Sum();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
return amount;
|
||||
}
|
||||
|
||||
|
||||
float AllocationCollege(List<YearOfPlan> plans, List<Month> months, int unitId)
|
||||
{
|
||||
var schedules = context.ScheduleOfColleges.Where(s => plans.Contains(s.YearOfPlan) && s.ScheduleText.OuId == unitId).ToList();
|
||||
float amount = 0;
|
||||
foreach (var schedule in schedules)
|
||||
{
|
||||
foreach (var month in months)
|
||||
{
|
||||
amount += GetMonthAmountForScheduleCollege(schedule, month.MonthId);
|
||||
}
|
||||
}
|
||||
|
||||
return amount;
|
||||
}
|
||||
|
||||
float RequestCollege(List<YearOfPlan> plans, List<Month> months, int unitId)
|
||||
{
|
||||
var requests = context.RequestsFromColleges.Where(r => months.Contains(r.Month) && plans.Contains(r.Schedule.YearOfPlan) && r.Schedule.ScheduleText.OuId == unitId);
|
||||
|
||||
float amount = 0;
|
||||
|
||||
if (requests.Count() != 0)
|
||||
{
|
||||
amount = requests.Select(r => r.RequestAmount).Sum();
|
||||
}
|
||||
try
|
||||
{
|
||||
amount = requests.Select(r => r.RequestAmount).Sum();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
return amount;
|
||||
}
|
||||
|
||||
float ManagerCollege(List<YearOfPlan> plans, List<Month> months, int unitId)
|
||||
{
|
||||
var requests = context.RequestsFromColleges.Where(r => months.Contains(r.Month) && plans.Contains(r.Schedule.YearOfPlan) && r.Schedule.ScheduleText.OuId == unitId);
|
||||
|
||||
float amount = 0;
|
||||
|
||||
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
amount = requests.Select(r => r.ManagerAmount).Sum();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
return amount;
|
||||
}
|
||||
|
||||
float PaymentCollege(List<YearOfPlan> plans, List<Month> months, int unitId)
|
||||
{
|
||||
var requests = context.RequestsFromColleges.Where(r => months.Contains(r.Month) && plans.Contains(r.Schedule.YearOfPlan) && r.Schedule.ScheduleText.OuId == unitId);
|
||||
|
||||
float amount = 0;
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
amount = requests.Select(r => r.PaymentAmount).Sum();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
return amount;
|
||||
}
|
||||
|
||||
private float GetMonthAmountForScheduleOu(ScheduleOfOU schedule, int monthId)
|
||||
{
|
||||
|
||||
switch (monthId)
|
||||
{
|
||||
case 1:
|
||||
return schedule.Farvardin;
|
||||
case 2:
|
||||
return schedule.Ordibehesht;
|
||||
case 3:
|
||||
return schedule.Khordad;
|
||||
case 4:
|
||||
return schedule.Tir;
|
||||
case 5:
|
||||
return schedule.Mordad;
|
||||
case 6:
|
||||
return schedule.Shahrivar;
|
||||
case 7:
|
||||
return schedule.Mehr;
|
||||
case 8:
|
||||
return schedule.Aban;
|
||||
case 9:
|
||||
return schedule.Azar;
|
||||
case 10:
|
||||
return schedule.Dey;
|
||||
case 11:
|
||||
return schedule.Bahman;
|
||||
case 12:
|
||||
return schedule.Esfand;
|
||||
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
private float GetMonthAmountForScheduleCollege(ScheduleOfCollege schedule, int monthId)
|
||||
{
|
||||
|
||||
switch (monthId)
|
||||
{
|
||||
case 1:
|
||||
return schedule.Farvardin;
|
||||
case 2:
|
||||
return schedule.Ordibehesht;
|
||||
case 3:
|
||||
return schedule.Khordad;
|
||||
case 4:
|
||||
return schedule.Tir;
|
||||
case 5:
|
||||
return schedule.Mordad;
|
||||
case 6:
|
||||
return schedule.Shahrivar;
|
||||
case 7:
|
||||
return schedule.Mehr;
|
||||
case 8:
|
||||
return schedule.Aban;
|
||||
case 9:
|
||||
return schedule.Azar;
|
||||
case 10:
|
||||
return schedule.Dey;
|
||||
case 11:
|
||||
return schedule.Bahman;
|
||||
case 12:
|
||||
return schedule.Esfand;
|
||||
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public List<ReportUnitViewModel> GetReportUnit(List<YearOfPlan> plans, List<Month> months, int titleId)
|
||||
{
|
||||
List<ReportUnitViewModel> lst = new List<ReportUnitViewModel>();
|
||||
|
||||
ScheduleText title = context.ScheduleText.Find(titleId);
|
||||
|
||||
OrganizationalUnit ou = title.OU;
|
||||
|
||||
|
||||
|
||||
//List<ScheduleOfOU> schedules = title.SchedulesOfOu.Where(s => plans.Contains(s.YearOfPlan)).ToList();
|
||||
List<ScheduleOfOU> schedules = context.SchedulesOf_OU.Where(s => s.OU_Id == ou.OU_Id && s.ScheduleTextId == title.ScheduleTextId && plans.Contains(s.YearOfPlan)).ToList();
|
||||
|
||||
|
||||
ReportUnitViewModel item = new ReportUnitViewModel();
|
||||
item.OuId = ou.OU_Id;
|
||||
item.UnitTitle = ou.OU_Title;
|
||||
|
||||
foreach (var schedule in schedules)
|
||||
{
|
||||
var allReq = context.RequestsFromUnits.Where(r => r.ScheduleId == schedule.ScheduleId);
|
||||
var request = allReq.Where(r => months.Contains(r.Month)).ToList();
|
||||
//var request = schedule.RequestsFromUnit.Where(r => months.Contains(r.Month)).ToList();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
item.RequestAmount += request.Select(r => r.RequestAmount).Sum();
|
||||
item.ManagerAmount += request.Select(r => r.ManagerAmount).Sum();
|
||||
item.PaymentAmount += request.Select(r => r.PaymentAmount).Sum();
|
||||
|
||||
foreach (var month in months)
|
||||
{
|
||||
item.AllocationAmount += GetMonthAmountForScheduleOu(schedule, month.MonthId);
|
||||
|
||||
}
|
||||
}
|
||||
lst.Add(item);
|
||||
|
||||
return lst;
|
||||
}
|
||||
|
||||
float AllocationOfOU(List<YearOfPlan> plans, List<Month> months, List<ScheduleOfOU> inputSchedules)
|
||||
{
|
||||
var schedules = inputSchedules;
|
||||
float amount = 0;
|
||||
foreach (var schedule in schedules)
|
||||
{
|
||||
foreach (var month in months)
|
||||
{
|
||||
amount += GetMonthAmountForScheduleOu(schedule, month.MonthId);
|
||||
}
|
||||
}
|
||||
|
||||
return amount;
|
||||
|
||||
}
|
||||
|
||||
public List<ReportCollegeViewModel> GetReportCollege(List<YearOfPlan> plans, List<Month> months, int titleId)
|
||||
{
|
||||
List<ReportCollegeViewModel> lst = new List<ReportCollegeViewModel>();
|
||||
ScheduleText title = context.ScheduleText.Find(titleId);
|
||||
var colleges = context.Colleges.ToList();
|
||||
|
||||
foreach (var college in colleges)
|
||||
{
|
||||
ReportCollegeViewModel item = new ReportCollegeViewModel();
|
||||
item.College = college;
|
||||
|
||||
List<ScheduleOfCollege> schedules = context.ScheduleOfColleges
|
||||
.Where(s => s.CollegeId == college.CollegeId &&
|
||||
s.ScheduleTextId == title.ScheduleTextId &&
|
||||
plans.Contains(s.YearOfPlan)
|
||||
).ToList();
|
||||
foreach (var schedule in schedules)
|
||||
{
|
||||
foreach (var month in months)
|
||||
{
|
||||
item.AllocationAmount += GetMonthAmountForScheduleCollege(schedule, month.MonthId);
|
||||
}
|
||||
var request = context.RequestsFromColleges.Where(r =>
|
||||
r.ScheduleId == schedule.ScheduleId &&
|
||||
months.Contains(r.Month)
|
||||
).ToList();
|
||||
|
||||
item.RequestAmount += request.Select(r => r.RequestAmount).Sum();
|
||||
item.OuAmount += request.Select(r => r.OU_Amount).Sum();
|
||||
item.ManagerAmount += request.Select(r => r.ManagerAmount).Sum();
|
||||
item.PaymentAmount += request.Select(r => r.PaymentAmount).Sum();
|
||||
}
|
||||
|
||||
lst.Add(item);
|
||||
}
|
||||
return lst;
|
||||
}
|
||||
|
||||
|
||||
public void CreateFirstSheet(ExcelWorksheet sheet, string PlanList, string MonthList, int row = 1)
|
||||
{
|
||||
int cul = 1;
|
||||
|
||||
sheet.Cells[GetCell(1, row)].Value = "تاریخ";
|
||||
sheet.Cells[GetCell(2, row)].Value = DateTime.Now.ToShamsi();
|
||||
row++;
|
||||
sheet.Cells[GetCell(1, row)].Value = "ساعت";
|
||||
sheet.Cells[GetCell(2,row)].Value = DateTime.Now.ToString("HH:mm");
|
||||
row++;
|
||||
sheet.Cells[GetCell(1, row)].Value = "سال";
|
||||
sheet.Cells[GetCell(2, row)].Value = PlanList;
|
||||
row++;
|
||||
sheet.Cells[GetCell(1, row)].Value = "ماه";
|
||||
sheet.Cells[GetCell(2, row)].Value = MonthList;
|
||||
|
||||
sheet.Cells["A:AZ"].AutoFitColumns();
|
||||
|
||||
}
|
||||
|
||||
public async Task<MemoryStream> ConvertorExcel(List<YearOfPlan> plans, List<Month> months)
|
||||
{
|
||||
string PlanList = "";
|
||||
string MonthList = "";
|
||||
foreach (var p in plans)
|
||||
{
|
||||
PlanList += p.YearNumber + " , ";
|
||||
}
|
||||
foreach (var m in months)
|
||||
{
|
||||
MonthList += m.MonthTitle + " , ";
|
||||
}
|
||||
|
||||
var unitList = await GetReportUnit(plans, months);
|
||||
ExcelPackage.LicenseContext = LicenseContext.NonCommercial;
|
||||
|
||||
ExcelPackage excelPackage = new ExcelPackage();
|
||||
|
||||
ExcelWorksheet Start = excelPackage.Workbook.Worksheets.Add("اطلاعات گزارش");
|
||||
|
||||
Start.Cells["A1"].Value = "تاریخ";
|
||||
Start.Cells["B1"].Value = DateTime.Now.ToShamsi();
|
||||
|
||||
Start.Cells["A2"].Value = "ساعت";
|
||||
Start.Cells["B2"].Value = DateTime.Now.ToString("HH:mm");
|
||||
|
||||
Start.Cells["A3"].Value = "سال";
|
||||
Start.Cells["B3"].Value = PlanList;
|
||||
|
||||
Start.Cells["A4"].Value = "ماه";
|
||||
Start.Cells["B4"].Value = MonthList;
|
||||
|
||||
Start.Cells["A:AZ"].AutoFitColumns();
|
||||
|
||||
|
||||
|
||||
|
||||
ExcelWorksheet ReportAllSheet = excelPackage.Workbook.Worksheets.Add("گزارش کلی");
|
||||
ReportAllSheet.Cells["A1"].Value = "واحد سازمانی";
|
||||
ReportAllSheet.Cells["B1"].Value = "تخصیص";
|
||||
ReportAllSheet.Cells["C1"].Value = "درخواست";
|
||||
ReportAllSheet.Cells["D1"].Value = "تایید واحد سازمانی";
|
||||
ReportAllSheet.Cells["E1"].Value = "نهایی";
|
||||
ReportAllSheet.Cells["F1"].Value = "پرداختی";
|
||||
int row = 2;
|
||||
foreach (var ous in unitList)
|
||||
{
|
||||
ReportAllSheet.Cells[string.Format("A{0}", row)].Value = ous.UnitTitle;
|
||||
ReportAllSheet.Cells[string.Format("B{0}", row)].Value = ous.AllocationAmount;
|
||||
ReportAllSheet.Cells[string.Format("C{0}", row)].Value = ous.RequestAmount;
|
||||
ReportAllSheet.Cells[string.Format("D{0}", row)].Value = ous.Ou_Amount;
|
||||
ReportAllSheet.Cells[string.Format("E{0}", row)].Value = ous.ManagerAmount;
|
||||
ReportAllSheet.Cells[string.Format("F{0}", row)].Value = ous.PaymentAmount;
|
||||
row++;
|
||||
}
|
||||
ReportAllSheet.Cells[string.Format("A{0}", row)].Value = "مجموع";
|
||||
ReportAllSheet.Cells[string.Format("B{0}", row)].Value = unitList.Select(u => u.AllocationAmount).Sum();
|
||||
ReportAllSheet.Cells[string.Format("C{0}", row)].Value = unitList.Select(u => u.RequestAmount).Sum();
|
||||
ReportAllSheet.Cells[string.Format("D{0}", row)].Value = unitList.Select(u => u.Ou_Amount).Sum();
|
||||
ReportAllSheet.Cells[string.Format("E{0}", row)].Value = unitList.Select(u => u.ManagerAmount).Sum();
|
||||
ReportAllSheet.Cells[string.Format("F{0}", row)].Value = unitList.Select(u => u.PaymentAmount).Sum();
|
||||
row++;
|
||||
|
||||
|
||||
ReportAllSheet.Cells["A:AZ"].AutoFitColumns();
|
||||
|
||||
|
||||
|
||||
|
||||
foreach (var unit in unitList)
|
||||
{
|
||||
row = 1;
|
||||
ExcelWorksheet ouSheet = excelPackage.Workbook.Worksheets.Add(unit.UnitTitle);
|
||||
|
||||
List<ScheduleText> Titles = context.ScheduleText.Where(s => s.OuId == unit.OuId).ToList();
|
||||
int cell = 1;
|
||||
ouSheet.Cells[GetCell(cell, row)].Value = "عنوان برنامه";
|
||||
cell++;
|
||||
ouSheet.Cells[GetCell(cell, row)].Value = unit.UnitTitle;
|
||||
cell++;
|
||||
List<College> Colleges = context.Colleges.ToList();
|
||||
foreach (var college in Colleges)
|
||||
{
|
||||
ouSheet.Cells[GetCell(cell, row)].Value = college.CollegeTitle;
|
||||
cell++;
|
||||
}
|
||||
row++;
|
||||
|
||||
foreach (var title in Titles)
|
||||
{
|
||||
cell = 1;
|
||||
var ou = GetReportUnit(plans, months, title.ScheduleTextId);
|
||||
var colleges = GetReportCollege(plans, months, title.ScheduleTextId);
|
||||
ouSheet.Cells[GetCell(cell, row)].Value = title.ScheduleTextTitle;
|
||||
cell++;
|
||||
foreach (var u in ou)
|
||||
{
|
||||
ouSheet.Cells[GetCell(cell, row)].Value = u.RequestAmount;
|
||||
cell++;
|
||||
}
|
||||
foreach (var college in colleges)
|
||||
{
|
||||
ouSheet.Cells[GetCell(cell, row)].Value = college.OuAmount;
|
||||
cell++;
|
||||
}
|
||||
row++;
|
||||
|
||||
|
||||
}
|
||||
|
||||
cell = 1;
|
||||
ouSheet.Cells[GetCell(cell, row)].Value = "مجموع";
|
||||
cell++;
|
||||
ouSheet.Cells[GetCell(cell, row)].Value = RequestReportOfUnit(plans, months, unit.OuId);
|
||||
foreach (var college in Colleges)
|
||||
{
|
||||
cell++;
|
||||
ouSheet.Cells[GetCell(cell, row)].Value = RequestReportOfCollege(plans, months, unit.OuId, college.CollegeId);
|
||||
}
|
||||
ouSheet.Cells["A:AZ"].AutoFitColumns();
|
||||
}
|
||||
using (MemoryStream stream = new MemoryStream())
|
||||
{
|
||||
stream.Write(excelPackage.GetAsByteArray());
|
||||
return stream;
|
||||
}
|
||||
}
|
||||
|
||||
private string GetExcelColumnName(int columnNumber)
|
||||
{
|
||||
string columnName = "";
|
||||
|
||||
while (columnNumber > 0)
|
||||
{
|
||||
int modulo = (columnNumber - 1) % 26;
|
||||
columnName = Convert.ToChar('A' + modulo) + columnName;
|
||||
columnNumber = (columnNumber - modulo) / 26;
|
||||
}
|
||||
|
||||
return columnName;
|
||||
}
|
||||
|
||||
private string GetCell(int columnNumber, int rowNumber)
|
||||
{
|
||||
string result = GetExcelColumnName(columnNumber);
|
||||
return result + rowNumber.ToString();
|
||||
}
|
||||
|
||||
public float RequestReportOfUnit(List<YearOfPlan> plans, List<Month> months, int ouId)
|
||||
{
|
||||
return context.RequestsFromUnits.Where(r => r.Schedule.ScheduleText.OuId == ouId &&
|
||||
months.Contains(r.Month) &&
|
||||
plans.Contains(r.Schedule.YearOfPlan))
|
||||
.Select(r => r.RequestAmount)
|
||||
.Sum();
|
||||
}
|
||||
|
||||
public float RequestReportOfCollege(List<YearOfPlan> plans, List<Month> months, int ouId, int collegeId)
|
||||
{
|
||||
return context.RequestsFromColleges.Where(r => r.Schedule.ScheduleText.OuId == ouId &&
|
||||
r.Schedule.CollegeId == collegeId &&
|
||||
months.Contains(r.Month) &&
|
||||
plans.Contains(r.Schedule.YearOfPlan))
|
||||
.Select(r => r.OU_Amount)
|
||||
.Sum();
|
||||
}
|
||||
|
||||
public async Task<MemoryStream> ConvertScheduleOfOuToExcel(List<ScheduleOfOuByFilterViewModel> schedules,string plan,string month,string ouTitle)
|
||||
{
|
||||
ExcelPackage.LicenseContext = LicenseContext.NonCommercial;
|
||||
|
||||
ExcelPackage excelPackage = new ExcelPackage();
|
||||
await Task.Delay(1);
|
||||
ExcelWorksheet Start = excelPackage.Workbook.Worksheets.Add("اطلاعات گزارش");
|
||||
|
||||
int row = 1;
|
||||
int cul = 1;
|
||||
|
||||
Start.Cells[GetCell(1, row)].Value = "واحد سازمانی";
|
||||
Start.Cells[GetCell(2, row)].Value = ouTitle;
|
||||
|
||||
row++;
|
||||
CreateFirstSheet(Start,plan,month,row);
|
||||
|
||||
ExcelWorksheet content = excelPackage.Workbook.Worksheets.Add("اطلاعات");
|
||||
List<string> headers = new List<string>();
|
||||
headers.Add(typeof(ScheduleOfOuByFilterViewModel).GetProperty("Plan").GetCustomAttributes(typeof(DisplayAttribute), true).Cast<DisplayAttribute>().FirstOrDefault().Name);
|
||||
headers.Add(typeof(ScheduleOfOuByFilterViewModel).GetProperty("Month").GetCustomAttributes(typeof(DisplayAttribute), true).Cast<DisplayAttribute>().FirstOrDefault().Name);
|
||||
headers.Add(typeof(ScheduleOfOuByFilterViewModel).GetProperty("ScheduleTitle").GetCustomAttributes(typeof(DisplayAttribute), true).Cast<DisplayAttribute>().FirstOrDefault().Name);
|
||||
headers.Add(typeof(RequestFromUnit).GetProperty("AllocationAmount").GetCustomAttributes(typeof(DisplayAttribute), true).Cast<DisplayAttribute>().FirstOrDefault().Name);
|
||||
headers.Add(typeof(RequestFromUnit).GetProperty("RequestAmount").GetCustomAttributes(typeof(DisplayAttribute), true).Cast<DisplayAttribute>().FirstOrDefault().Name);
|
||||
headers.Add(typeof(RequestFromUnit).GetProperty("ManagerAmount").GetCustomAttributes(typeof(DisplayAttribute), true).Cast<DisplayAttribute>().FirstOrDefault().Name);
|
||||
headers.Add(typeof(RequestFromUnit).GetProperty("PaymentAmount").GetCustomAttributes(typeof(DisplayAttribute), true).Cast<DisplayAttribute>().FirstOrDefault().Name);
|
||||
headers.Add(typeof(ScheduleOfOuByFilterViewModel).GetProperty("Target").GetCustomAttributes(typeof(DisplayAttribute), true).Cast<DisplayAttribute>().FirstOrDefault().Name);
|
||||
headers.Add(typeof(ScheduleOfOuByFilterViewModel).GetProperty("Strategy").GetCustomAttributes(typeof(DisplayAttribute), true).Cast<DisplayAttribute>().FirstOrDefault().Name);
|
||||
headers.Add(typeof(ScheduleOfOuByFilterViewModel).GetProperty("CostIndex").GetCustomAttributes(typeof(DisplayAttribute), true).Cast<DisplayAttribute>().FirstOrDefault().Name);
|
||||
headers.Add(typeof(ScheduleOfOuByFilterViewModel).GetProperty("AppTypeId").GetCustomAttributes(typeof(DisplayAttribute), true).Cast<DisplayAttribute>().FirstOrDefault().Name);
|
||||
headers.Add(typeof(ScheduleOfOuByFilterViewModel).GetProperty("LevelId").GetCustomAttributes(typeof(DisplayAttribute), true).Cast<DisplayAttribute>().FirstOrDefault().Name);
|
||||
headers.Add(typeof(ScheduleOfOuByFilterViewModel).GetProperty("Priority").GetCustomAttributes(typeof(DisplayAttribute), true).Cast<DisplayAttribute>().FirstOrDefault().Name);
|
||||
headers.Add(typeof(ScheduleOfOuByFilterViewModel).GetProperty("Importance").GetCustomAttributes(typeof(DisplayAttribute), true).Cast<DisplayAttribute>().FirstOrDefault().Name);
|
||||
headers.Add(typeof(ScheduleOfOuByFilterViewModel).GetProperty("Quantity").GetCustomAttributes(typeof(DisplayAttribute), true).Cast<DisplayAttribute>().FirstOrDefault().Name);
|
||||
headers.Add(typeof(ScheduleOfOuByFilterViewModel).GetProperty("RevenueIndex").GetCustomAttributes(typeof(DisplayAttribute), true).Cast<DisplayAttribute>().FirstOrDefault().Name);
|
||||
headers.Add(typeof(ScheduleOfOuByFilterViewModel).GetProperty("TestIndex").GetCustomAttributes(typeof(DisplayAttribute), true).Cast<DisplayAttribute>().FirstOrDefault().Name);
|
||||
headers.Add(typeof(ScheduleOfOuByFilterViewModel).GetProperty("TotalCost").GetCustomAttributes(typeof(DisplayAttribute), true).Cast<DisplayAttribute>().FirstOrDefault().Name);
|
||||
AddHeaderForSheet(content,headers,cul,row);
|
||||
foreach (var schedule in schedules)
|
||||
{
|
||||
row++;
|
||||
cul = 1;
|
||||
|
||||
content.Cells[GetCell(cul, row)].Value = schedule.Plan.YearNumber;
|
||||
cul++;
|
||||
content.Cells[GetCell(cul, row)].Value = schedule.Month.MonthTitle ;
|
||||
cul++;
|
||||
content.Cells[GetCell(cul, row)].Value = schedule.ScheduleTitle.ScheduleTextTitle ;
|
||||
cul++;
|
||||
content.Cells[GetCell(cul, row)].Value = schedule.Request.AllocationAmount ;
|
||||
cul++;
|
||||
content.Cells[GetCell(cul, row)].Value = schedule.Request.RequestAmount ;
|
||||
cul++;
|
||||
content.Cells[GetCell(cul, row)].Value = schedule.Request.ManagerAmount ;
|
||||
cul++;
|
||||
content.Cells[GetCell(cul, row)].Value = schedule.Request.PaymentAmount ;
|
||||
cul++;
|
||||
content.Cells[GetCell(cul, row)].Value = schedule.Target;
|
||||
cul++;
|
||||
content.Cells[GetCell(cul, row)].Value = schedule.Strategy ;
|
||||
cul++;
|
||||
content.Cells[GetCell(cul, row)].Value = schedule.CostIndex;
|
||||
cul++;
|
||||
content.Cells[GetCell(cul, row)].Value = schedule.AppTypeId;
|
||||
cul++;
|
||||
content.Cells[GetCell(cul, row)].Value = schedule.LevelId ;
|
||||
cul++;
|
||||
content.Cells[GetCell(cul, row)].Value = schedule.Priority;
|
||||
cul++;
|
||||
content.Cells[GetCell(cul, row)].Value = schedule.Importance;
|
||||
cul++;
|
||||
content.Cells[GetCell(cul, row)].Value = schedule.Quantity ;
|
||||
cul++;
|
||||
content.Cells[GetCell(cul, row)].Value = schedule.RevenueIndex ;
|
||||
cul++;
|
||||
content.Cells[GetCell(cul, row)].Value = schedule.TestIndex;
|
||||
cul++;
|
||||
content.Cells[GetCell(cul, row)].Value = schedule.TotalCost ;
|
||||
cul++;
|
||||
}
|
||||
content.Cells["A:AZ"].AutoFitColumns();
|
||||
await Task.Delay(1);
|
||||
using (MemoryStream stream = new MemoryStream())
|
||||
{
|
||||
stream.Write(excelPackage.GetAsByteArray());
|
||||
return stream;
|
||||
}
|
||||
}
|
||||
|
||||
void AddHeaderForSheet(ExcelWorksheet sheet,List<string> headers,int cul = 1, int row = 1)
|
||||
{
|
||||
foreach (var header in headers)
|
||||
{
|
||||
sheet.Cells[GetCell(cul, row)].Value = header;
|
||||
cul++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public async Task<MemoryStream> ConvertScheduleOfCoToExcel(List<ScheduleOfCollegeByFilterViewModel> schedules, string plan, string month, string college)
|
||||
{
|
||||
ExcelPackage.LicenseContext = LicenseContext.NonCommercial;
|
||||
|
||||
ExcelPackage excelPackage = new ExcelPackage();
|
||||
ExcelWorksheet Start = excelPackage.Workbook.Worksheets.Add("اطلاعات گزارش");
|
||||
|
||||
int row = 1;
|
||||
int cul = 1;
|
||||
|
||||
Start.Cells[GetCell(1, row)].Value = "دانشکده";
|
||||
Start.Cells[GetCell(2, row)].Value = college;
|
||||
row++;
|
||||
CreateFirstSheet(Start, plan, month, row);
|
||||
|
||||
Start.Cells[GetCell(1, 6)].Value = "واحد سازمانی";
|
||||
Start.Cells[GetCell(2, 6)].Value = schedules.Distinct().Select(s => s.ScheduleTitle.OU.OU_Title).ToArray();
|
||||
|
||||
ExcelWorksheet content = excelPackage.Workbook.Worksheets.Add("اطلاعات");
|
||||
List<string> headers = new List<string>();
|
||||
headers.Add(typeof(ScheduleOfCollegeByFilterViewModel).GetProperty("Plan").GetCustomAttributes(typeof(DisplayAttribute), true).Cast<DisplayAttribute>().FirstOrDefault().Name);
|
||||
headers.Add(typeof(ScheduleOfCollegeByFilterViewModel).GetProperty("Month").GetCustomAttributes(typeof(DisplayAttribute), true).Cast<DisplayAttribute>().FirstOrDefault().Name);
|
||||
headers.Add(typeof(ScheduleText).GetProperty("OU").GetCustomAttributes(typeof(DisplayAttribute), true).Cast<DisplayAttribute>().FirstOrDefault().Name);
|
||||
headers.Add(typeof(ScheduleOfCollegeByFilterViewModel).GetProperty("ScheduleTitle").GetCustomAttributes(typeof(DisplayAttribute), true).Cast<DisplayAttribute>().FirstOrDefault().Name);
|
||||
headers.Add(typeof(RequestFromCollege).GetProperty("AllocationAmount").GetCustomAttributes(typeof(DisplayAttribute), true).Cast<DisplayAttribute>().FirstOrDefault().Name);
|
||||
headers.Add(typeof(RequestFromCollege).GetProperty("RequestAmount").GetCustomAttributes(typeof(DisplayAttribute), true).Cast<DisplayAttribute>().FirstOrDefault().Name);
|
||||
headers.Add(typeof(RequestFromCollege).GetProperty("OU_Amount").GetCustomAttributes(typeof(DisplayAttribute), true).Cast<DisplayAttribute>().FirstOrDefault().Name);
|
||||
headers.Add(typeof(RequestFromCollege).GetProperty("ManagerAmount").GetCustomAttributes(typeof(DisplayAttribute), true).Cast<DisplayAttribute>().FirstOrDefault().Name);
|
||||
headers.Add(typeof(RequestFromCollege).GetProperty("PaymentAmount").GetCustomAttributes(typeof(DisplayAttribute), true).Cast<DisplayAttribute>().FirstOrDefault().Name);
|
||||
headers.Add(typeof(ScheduleOfCollegeByFilterViewModel).GetProperty("Target").GetCustomAttributes(typeof(DisplayAttribute), true).Cast<DisplayAttribute>().FirstOrDefault().Name);
|
||||
headers.Add(typeof(ScheduleOfCollegeByFilterViewModel).GetProperty("Strategy").GetCustomAttributes(typeof(DisplayAttribute), true).Cast<DisplayAttribute>().FirstOrDefault().Name);
|
||||
headers.Add(typeof(ScheduleOfCollegeByFilterViewModel).GetProperty("CostIndex").GetCustomAttributes(typeof(DisplayAttribute), true).Cast<DisplayAttribute>().FirstOrDefault().Name);
|
||||
headers.Add(typeof(ScheduleOfCollegeByFilterViewModel).GetProperty("AppTypeId").GetCustomAttributes(typeof(DisplayAttribute), true).Cast<DisplayAttribute>().FirstOrDefault().Name);
|
||||
headers.Add(typeof(ScheduleOfCollegeByFilterViewModel).GetProperty("LevelId").GetCustomAttributes(typeof(DisplayAttribute), true).Cast<DisplayAttribute>().FirstOrDefault().Name);
|
||||
headers.Add(typeof(ScheduleOfCollegeByFilterViewModel).GetProperty("Priority").GetCustomAttributes(typeof(DisplayAttribute), true).Cast<DisplayAttribute>().FirstOrDefault().Name);
|
||||
headers.Add(typeof(ScheduleOfCollegeByFilterViewModel).GetProperty("Importance").GetCustomAttributes(typeof(DisplayAttribute), true).Cast<DisplayAttribute>().FirstOrDefault().Name);
|
||||
headers.Add(typeof(ScheduleOfCollegeByFilterViewModel).GetProperty("Quantity").GetCustomAttributes(typeof(DisplayAttribute), true).Cast<DisplayAttribute>().FirstOrDefault().Name);
|
||||
headers.Add(typeof(ScheduleOfCollegeByFilterViewModel).GetProperty("RevenueIndex").GetCustomAttributes(typeof(DisplayAttribute), true).Cast<DisplayAttribute>().FirstOrDefault().Name);
|
||||
headers.Add(typeof(ScheduleOfCollegeByFilterViewModel).GetProperty("TestIndex").GetCustomAttributes(typeof(DisplayAttribute), true).Cast<DisplayAttribute>().FirstOrDefault().Name);
|
||||
headers.Add(typeof(ScheduleOfCollegeByFilterViewModel).GetProperty("TotalCost").GetCustomAttributes(typeof(DisplayAttribute), true).Cast<DisplayAttribute>().FirstOrDefault().Name);
|
||||
AddHeaderForSheet(content, headers, cul, row);
|
||||
|
||||
foreach (var schedule in schedules)
|
||||
{
|
||||
row++;
|
||||
cul = 1;
|
||||
|
||||
content.Cells[GetCell(cul, row)].Value = schedule.Plan.YearNumber;
|
||||
cul++;
|
||||
content.Cells[GetCell(cul, row)].Value = schedule.Month.MonthTitle;
|
||||
cul++;
|
||||
content.Cells[GetCell(cul, row)].Value = schedule.ScheduleTitle.OU.OU_Title;
|
||||
cul++;
|
||||
content.Cells[GetCell(cul, row)].Value = schedule.ScheduleTitle.ScheduleTextTitle;
|
||||
cul++;
|
||||
content.Cells[GetCell(cul, row)].Value = schedule.Request.AllocationAmount;
|
||||
cul++;
|
||||
content.Cells[GetCell(cul, row)].Value = schedule.Request.RequestAmount;
|
||||
cul++;
|
||||
content.Cells[GetCell(cul, row)].Value = schedule.Request.OU_Amount;
|
||||
cul++;
|
||||
content.Cells[GetCell(cul, row)].Value = schedule.Request.ManagerAmount;
|
||||
cul++;
|
||||
content.Cells[GetCell(cul, row)].Value = schedule.Request.PaymentAmount;
|
||||
cul++;
|
||||
content.Cells[GetCell(cul, row)].Value = schedule.Target;
|
||||
cul++;
|
||||
content.Cells[GetCell(cul, row)].Value = schedule.Strategy;
|
||||
cul++;
|
||||
content.Cells[GetCell(cul, row)].Value = schedule.CostIndex;
|
||||
cul++;
|
||||
content.Cells[GetCell(cul, row)].Value = schedule.AppTypeId;
|
||||
cul++;
|
||||
content.Cells[GetCell(cul, row)].Value = schedule.LevelId;
|
||||
cul++;
|
||||
content.Cells[GetCell(cul, row)].Value = schedule.Priority;
|
||||
cul++;
|
||||
content.Cells[GetCell(cul, row)].Value = schedule.Importance;
|
||||
cul++;
|
||||
content.Cells[GetCell(cul, row)].Value = schedule.Quantity;
|
||||
cul++;
|
||||
content.Cells[GetCell(cul, row)].Value = schedule.RevenueIndex;
|
||||
cul++;
|
||||
content.Cells[GetCell(cul, row)].Value = schedule.TestIndex;
|
||||
cul++;
|
||||
content.Cells[GetCell(cul, row)].Value = schedule.TotalCost;
|
||||
cul++;
|
||||
}
|
||||
content.Cells["A:AZ"].AutoFitColumns();
|
||||
using (MemoryStream stream = new MemoryStream())
|
||||
{
|
||||
stream.Write(excelPackage.GetAsByteArray());
|
||||
return stream;
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<MemoryStream> ConvertFundingLogToExcel(List<ConfrimCollegeRequestForAdminViewModel> logs, string plan, string month, string college, string ous)
|
||||
{
|
||||
ExcelPackage.LicenseContext = LicenseContext.NonCommercial;
|
||||
|
||||
ExcelPackage excelPackage = new ExcelPackage();
|
||||
ExcelWorksheet Start = excelPackage.Workbook.Worksheets.Add("اطلاعات گزارش");
|
||||
|
||||
int row = 1;
|
||||
int cul = 1;
|
||||
CreateFirstSheet(Start, plan, month, row);
|
||||
row = 5;
|
||||
Start.Cells[GetCell(1, row)].Value = "دانشکده";
|
||||
Start.Cells[GetCell(2, row)].Value = college;
|
||||
row++;
|
||||
Start.Cells[GetCell(1, row)].Value = "واحد سازمانی";
|
||||
Start.Cells[GetCell(2, row)].Value = ous;
|
||||
|
||||
|
||||
|
||||
row = 1;
|
||||
|
||||
ExcelWorksheet content = excelPackage.Workbook.Worksheets.Add("اطلاعات");
|
||||
|
||||
List<string> headers = new List<string>();
|
||||
|
||||
headers.Add(typeof(ConfrimCollegeRequestForAdminViewModel).GetProperty("YearNumber").GetCustomAttributes(typeof(DisplayAttribute), true).Cast<DisplayAttribute>().FirstOrDefault().Name);
|
||||
|
||||
headers.Add(typeof(ConfrimCollegeRequestForAdminViewModel).GetProperty("MonthTitle").GetCustomAttributes(typeof(DisplayAttribute), true).Cast<DisplayAttribute>().FirstOrDefault().Name);
|
||||
headers.Add(typeof(ConfrimCollegeRequestForAdminViewModel).GetProperty("CollegeTitle").GetCustomAttributes(typeof(DisplayAttribute), true).Cast<DisplayAttribute>().FirstOrDefault().Name);
|
||||
|
||||
headers.Add(typeof(ConfrimCollegeRequestForAdminViewModel).GetProperty("UnitTitle").GetCustomAttributes(typeof(DisplayAttribute), true).Cast<DisplayAttribute>().FirstOrDefault().Name);
|
||||
headers.Add(typeof(ConfrimCollegeRequestForAdminViewModel).GetProperty("ScheduleTitle").GetCustomAttributes(typeof(DisplayAttribute), true).Cast<DisplayAttribute>().FirstOrDefault().Name);
|
||||
headers.Add(typeof(RequestFromCollege).GetProperty("AllocationAmount").GetCustomAttributes(typeof(DisplayAttribute), true).Cast<DisplayAttribute>().FirstOrDefault().Name);
|
||||
headers.Add(typeof(RequestFromCollege).GetProperty("RequestAmount").GetCustomAttributes(typeof(DisplayAttribute), true).Cast<DisplayAttribute>().FirstOrDefault().Name);
|
||||
headers.Add(typeof(RequestFromCollege).GetProperty("OU_Amount").GetCustomAttributes(typeof(DisplayAttribute), true).Cast<DisplayAttribute>().FirstOrDefault().Name);
|
||||
headers.Add(typeof(RequestFromCollege).GetProperty("ManagerAmount").GetCustomAttributes(typeof(DisplayAttribute), true).Cast<DisplayAttribute>().FirstOrDefault().Name);
|
||||
headers.Add(typeof(RequestFromCollege).GetProperty("PaymentAmount").GetCustomAttributes(typeof(DisplayAttribute), true).Cast<DisplayAttribute>().FirstOrDefault().Name);
|
||||
|
||||
AddHeaderForSheet(content, headers, cul, row);
|
||||
row++;
|
||||
content.Cells[GetCell(1, row)].Value = "مجموع";
|
||||
content.Cells[GetCell(6, row)].Value = logs.Select(l => l.Request.AllocationAmount).Sum().ToString("#,0") ;
|
||||
content.Cells[GetCell(7, row)].Value = logs.Select(l => l.Request.RequestAmount).Sum().ToString("#,0");
|
||||
content.Cells[GetCell(8, row)].Value = logs.Select(l => l.Request.OU_Amount).Sum().ToString("#,0");
|
||||
content.Cells[GetCell(9, row)].Value = logs.Select(l => l.Request.ManagerAmount).Sum().ToString("#,0");
|
||||
content.Cells[GetCell(10, row)].Value = logs.Select(l => l.Request.PaymentAmount).Sum().ToString("#,0");
|
||||
|
||||
foreach (var item in logs)
|
||||
{
|
||||
row++;
|
||||
cul = 1;
|
||||
|
||||
content.Cells[GetCell(cul, row)].Value = item.YearNumber;
|
||||
cul++;
|
||||
content.Cells[GetCell(cul, row)].Value = item.MonthTitle;
|
||||
cul++;
|
||||
content.Cells[GetCell(cul, row)].Value = item.CollegeTitle;
|
||||
cul++;
|
||||
content.Cells[GetCell(cul, row)].Value = item.UnitTitle;
|
||||
cul++;
|
||||
content.Cells[GetCell(cul, row)].Value = item.ScheduleTitle;
|
||||
cul++;
|
||||
content.Cells[GetCell(cul, row)].Value = item.Request.AllocationAmount;
|
||||
cul++;
|
||||
content.Cells[GetCell(cul, row)].Value = item.Request.RequestAmount;
|
||||
cul++;
|
||||
content.Cells[GetCell(cul, row)].Value = item.Request.OU_Amount;
|
||||
cul++;
|
||||
content.Cells[GetCell(cul, row)].Value = item.Request.ManagerAmount;
|
||||
cul++;
|
||||
content.Cells[GetCell(cul, row)].Value = item.Request.PaymentAmount;
|
||||
cul++;
|
||||
|
||||
}
|
||||
content.Cells["A:AZ"].AutoFitColumns();
|
||||
|
||||
using (MemoryStream stream = new MemoryStream())
|
||||
{
|
||||
stream.Write(excelPackage.GetAsByteArray());
|
||||
return stream;
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<MemoryStream> ConvertUnitLogToExcel(List<ConfirmUnitRequestForAdminViewModel> logs, string plan, string month, string ou)
|
||||
{
|
||||
ExcelPackage.LicenseContext = LicenseContext.NonCommercial;
|
||||
|
||||
ExcelPackage excelPackage = new ExcelPackage();
|
||||
ExcelWorksheet Start = excelPackage.Workbook.Worksheets.Add("اطلاعات گزارش");
|
||||
|
||||
int row = 1;
|
||||
int cul = 1;
|
||||
CreateFirstSheet(Start, plan, month, row);
|
||||
row = 5;
|
||||
Start.Cells[GetCell(1, row)].Value = "واحد سازمانی";
|
||||
Start.Cells[GetCell(2, row)].Value = ou;
|
||||
row = 1;
|
||||
ExcelWorksheet content = excelPackage.Workbook.Worksheets.Add("اطلاعات");
|
||||
|
||||
List<string> headers = new List<string>();
|
||||
|
||||
headers.Add(typeof(ConfirmUnitRequestForAdminViewModel).GetProperty("YearNumber").GetCustomAttributes(typeof(DisplayAttribute), true).Cast<DisplayAttribute>().FirstOrDefault().Name);
|
||||
|
||||
headers.Add(typeof(ConfirmUnitRequestForAdminViewModel).GetProperty("MonthTitle").GetCustomAttributes(typeof(DisplayAttribute), true).Cast<DisplayAttribute>().FirstOrDefault().Name);
|
||||
|
||||
headers.Add(typeof(ConfirmUnitRequestForAdminViewModel).GetProperty("UnitTitle").GetCustomAttributes(typeof(DisplayAttribute), true).Cast<DisplayAttribute>().FirstOrDefault().Name);
|
||||
headers.Add(typeof(ConfirmUnitRequestForAdminViewModel).GetProperty("ScheduleTitle").GetCustomAttributes(typeof(DisplayAttribute), true).Cast<DisplayAttribute>().FirstOrDefault().Name);
|
||||
headers.Add(typeof(RequestFromUnit).GetProperty("AllocationAmount").GetCustomAttributes(typeof(DisplayAttribute), true).Cast<DisplayAttribute>().FirstOrDefault().Name);
|
||||
headers.Add(typeof(RequestFromUnit).GetProperty("RequestAmount").GetCustomAttributes(typeof(DisplayAttribute), true).Cast<DisplayAttribute>().FirstOrDefault().Name);
|
||||
headers.Add(typeof(RequestFromUnit).GetProperty("ManagerAmount").GetCustomAttributes(typeof(DisplayAttribute), true).Cast<DisplayAttribute>().FirstOrDefault().Name);
|
||||
headers.Add(typeof(RequestFromUnit).GetProperty("PaymentAmount").GetCustomAttributes(typeof(DisplayAttribute), true).Cast<DisplayAttribute>().FirstOrDefault().Name);
|
||||
|
||||
AddHeaderForSheet(content, headers, cul, row);
|
||||
row++;
|
||||
content.Cells[GetCell(1, row)].Value = "مجموع";
|
||||
content.Cells[GetCell(5, row)].Value = logs.Select(l => l.Request.AllocationAmount).Sum().ToString("#,0");
|
||||
content.Cells[GetCell(6, row)].Value = logs.Select(l => l.Request.RequestAmount).Sum().ToString("#,0");
|
||||
content.Cells[GetCell(7, row)].Value = logs.Select(l => l.Request.ManagerAmount).Sum().ToString("#,0");
|
||||
content.Cells[GetCell(8, row)].Value = logs.Select(l => l.Request.PaymentAmount).Sum().ToString("#,0");
|
||||
|
||||
|
||||
foreach (var item in logs)
|
||||
{
|
||||
row++;
|
||||
cul = 1;
|
||||
|
||||
content.Cells[GetCell(cul, row)].Value = item.YearNumber;
|
||||
cul++;
|
||||
content.Cells[GetCell(cul, row)].Value = item.MonthTitle;
|
||||
cul++;
|
||||
content.Cells[GetCell(cul, row)].Value = item.UnitTitle;
|
||||
cul++;
|
||||
content.Cells[GetCell(cul, row)].Value = item.ScheduleTitle;
|
||||
cul++;
|
||||
content.Cells[GetCell(cul, row)].Value = item.Request.AllocationAmount;
|
||||
cul++;
|
||||
content.Cells[GetCell(cul, row)].Value = item.Request.RequestAmount;
|
||||
cul++;
|
||||
content.Cells[GetCell(cul, row)].Value = item.Request.ManagerAmount;
|
||||
cul++;
|
||||
content.Cells[GetCell(cul, row)].Value = item.Request.PaymentAmount;
|
||||
cul++;
|
||||
|
||||
}
|
||||
content.Cells["A:AZ"].AutoFitColumns();
|
||||
|
||||
using (MemoryStream stream = new MemoryStream())
|
||||
{
|
||||
stream.Write(excelPackage.GetAsByteArray());
|
||||
return stream;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,387 @@
|
||||
using BlazorApp.Core.DTOs;
|
||||
using BlazorApp.DataLayer.Entities.Colleges.Schedule;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace BlazorApp.Core.Services
|
||||
{
|
||||
public partial class CollegeService : ICollegeService
|
||||
{
|
||||
public List<ScheduleOfCollege> GetSchedulesOfCollege(int collegeId, int planId)
|
||||
{
|
||||
return _context.ScheduleOfColleges
|
||||
.Where(s => s.CollegeId == collegeId && s.YearId == planId)
|
||||
.Include(s => s.ScheduleText.OU).Include(s => s.AppType).Include(s => s.Level).Include(s => s.Target).Include(s => s.Guideline).ToList();
|
||||
}
|
||||
|
||||
|
||||
public ServiceResponse<ScheduleOfCollege> GetScheduleOfCollege(int scheduleId)
|
||||
{
|
||||
var item = new ServiceResponse<ScheduleOfCollege>();
|
||||
try
|
||||
{
|
||||
item.SetData(_context.ScheduleOfColleges.Where(s => s.ScheduleId == scheduleId).Include(s => s.ScheduleText.OU).Include(s => s.AppType).Include(s => s.Level).SingleOrDefault());
|
||||
item.SetStatus(ResultStatus.Success);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
item.SetException(ex);
|
||||
item.SetStatus(ResultStatus.Error);
|
||||
}
|
||||
return item;
|
||||
}
|
||||
|
||||
public ServiceResponse<ScheduleOfCollege> CreateScheduleOfCollege(ScheduleOfCollege schedule)
|
||||
{
|
||||
var item = new ServiceResponse<ScheduleOfCollege>();
|
||||
try
|
||||
{
|
||||
|
||||
_context.ScheduleOfColleges.Add(schedule);
|
||||
_context.SaveChanges();
|
||||
item.SetData(schedule);
|
||||
item.SetStatus(ResultStatus.Success);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
item.SetException(ex);
|
||||
item.SetData(schedule);
|
||||
item.SetStatus(ResultStatus.Error);
|
||||
}
|
||||
return item;
|
||||
}
|
||||
|
||||
public ServiceResponse<ScheduleOfCollege> UpdateScheduleOfCollege(ScheduleOfCollege schedule)
|
||||
{
|
||||
var item = new ServiceResponse<ScheduleOfCollege>();
|
||||
try
|
||||
{
|
||||
//ScheduleOfCollege newSchedule = new ScheduleOfCollege()
|
||||
//{
|
||||
// ScheduleId = schedule.ScheduleId,
|
||||
// ScheduleTextId = schedule.ScheduleTextId,
|
||||
// TargetId = schedule.TargetId,
|
||||
// AppTypeId = schedule.AppTypeId,
|
||||
// CollegeId = schedule.CollegeId,
|
||||
// YearId = schedule.YearId,
|
||||
// LevelId = schedule.LevelId,
|
||||
// GuidelineId = schedule.GuidelineId,
|
||||
// CostIndex = schedule.CostIndex,
|
||||
// RevenueIndex = schedule.RevenueIndex,
|
||||
// Priority=schedule.Priority,
|
||||
// Importance=schedule.Importance,
|
||||
// TestIndex=schedule.TestIndex,
|
||||
// Quantity=schedule.Quantity,
|
||||
// Farvardin = schedule.Farvardin,
|
||||
// Ordibehesht = schedule.Ordibehesht,
|
||||
// Khordad = schedule.Khordad,
|
||||
// Tir = schedule.Tir,
|
||||
// Mordad = schedule.Mordad,
|
||||
// Shahrivar = schedule.Shahrivar,
|
||||
// Mehr = schedule.Mehr,
|
||||
// Aban = schedule.Aban,
|
||||
// Azar = schedule.Azar,
|
||||
// Dey = schedule.Dey,
|
||||
// Bahman = schedule.Bahman,
|
||||
// Esfand = schedule.Esfand,
|
||||
//};
|
||||
//schedule = newSchedule;
|
||||
|
||||
//schedule.College = null;
|
||||
//schedule.YearOfPlan = null;
|
||||
//schedule.AppType = null;
|
||||
//schedule.Level = null;
|
||||
//schedule.ScheduleText = null;
|
||||
//schedule.Target = null;
|
||||
//schedule.Guideline = null;
|
||||
|
||||
//ScheduleOfCollege oldSchedule = GetScheduleOfCollege(schedule.ScheduleId).Data;
|
||||
//oldSchedule.CollegeId = schedule.CollegeId;
|
||||
//oldSchedule.YearId = schedule.YearId;
|
||||
//oldSchedule.AppTypeId = schedule.AppTypeId;
|
||||
//oldSchedule.LevelId = schedule.LevelId;
|
||||
//oldSchedule.ScheduleTextId = schedule.ScheduleTextId;
|
||||
//oldSchedule.TargetId = schedule.TargetId;
|
||||
//oldSchedule.GuidelineId = schedule.GuidelineId;
|
||||
//oldSchedule.CostIndex = schedule.CostIndex;
|
||||
//oldSchedule.RevenueIndex = schedule.RevenueIndex;
|
||||
//oldSchedule.Priority = schedule.Priority;
|
||||
//oldSchedule.Importance = schedule.Importance;
|
||||
//oldSchedule.TestIndex = schedule.TestIndex;
|
||||
//oldSchedule.Quantity = schedule.Quantity;
|
||||
//oldSchedule.Farvardin = schedule.Farvardin;
|
||||
//oldSchedule.Ordibehesht = schedule.Ordibehesht;
|
||||
//oldSchedule.Khordad = schedule.Khordad;
|
||||
//oldSchedule.Tir = schedule.Tir;
|
||||
//oldSchedule.Mordad = schedule.Mordad;
|
||||
//oldSchedule.Shahrivar = schedule.Shahrivar;
|
||||
//oldSchedule.Mehr = schedule.Mehr;
|
||||
//oldSchedule.Aban = schedule.Aban;
|
||||
//oldSchedule.Azar = schedule.Azar;
|
||||
//oldSchedule.Dey = schedule.Dey;
|
||||
//oldSchedule.Bahman = schedule.Bahman;
|
||||
//oldSchedule.Esfand = schedule.Esfand;
|
||||
|
||||
|
||||
//ScheduleOfCollege old2 = GetScheduleOfCollege(schedule.ScheduleId).Data;
|
||||
|
||||
|
||||
|
||||
//_context.ScheduleOfColleges.Update(schedule);
|
||||
var request = _context.RequestsFromColleges.Where(r => r.ScheduleId == schedule.ScheduleId).ToList();
|
||||
foreach (var r in request)
|
||||
{
|
||||
for (int monthNumber = 1; monthNumber <= 12 ; monthNumber++)
|
||||
{
|
||||
if(r.MonthId == monthNumber)
|
||||
{
|
||||
r.AllocationAmount = getScheduleMonthAmount(monthNumber, schedule);
|
||||
_context.RequestsFromColleges.Update(r);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
_context.ScheduleOfColleges.Update(schedule);
|
||||
_context.SaveChanges();
|
||||
item.SetData(schedule);
|
||||
item.SetStatus(ResultStatus.Success);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
item.SetException(ex);
|
||||
item.SetData(schedule);
|
||||
item.SetStatus(ResultStatus.Error);
|
||||
}
|
||||
return item;
|
||||
}
|
||||
|
||||
float getScheduleMonthAmount(int monthId, ScheduleOfCollege schedule)
|
||||
{
|
||||
switch (monthId)
|
||||
{
|
||||
case 1:
|
||||
return schedule.Farvardin;
|
||||
break;
|
||||
case 2:
|
||||
return schedule.Ordibehesht;
|
||||
break;
|
||||
case 3:
|
||||
return schedule.Khordad;
|
||||
break;
|
||||
case 4:
|
||||
return schedule.Tir;
|
||||
break;
|
||||
case 5:
|
||||
return schedule.Mordad;
|
||||
break;
|
||||
case 6:
|
||||
return schedule.Shahrivar;
|
||||
break;
|
||||
case 7:
|
||||
return schedule.Mehr;
|
||||
break;
|
||||
case 8:
|
||||
return schedule.Aban;
|
||||
break;
|
||||
case 9:
|
||||
return schedule.Azar;
|
||||
break;
|
||||
case 10:
|
||||
return schedule.Dey;
|
||||
break;
|
||||
case 11:
|
||||
return schedule.Bahman;
|
||||
break;
|
||||
case 12:
|
||||
return schedule.Esfand;
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public ServiceResponse<ScheduleOfCollege> DeleteScheduleOfCollege(ScheduleOfCollege schedule)
|
||||
{
|
||||
var item = new ServiceResponse<ScheduleOfCollege>();
|
||||
try
|
||||
{
|
||||
_context.ScheduleOfColleges.Remove(schedule);
|
||||
_context.SaveChanges();
|
||||
item.SetData(schedule);
|
||||
item.SetStatus(ResultStatus.Success);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
item.SetException(ex);
|
||||
item.SetData(schedule);
|
||||
item.SetStatus(ResultStatus.Error);
|
||||
}
|
||||
return item;
|
||||
}
|
||||
|
||||
public float GetScheduleOfCollegeTotalAmount(int scheduleId)
|
||||
{
|
||||
ScheduleOfCollege schedule = GetScheduleOfCollege(scheduleId).Data;
|
||||
|
||||
float totalAmount = 0;
|
||||
totalAmount += schedule.Farvardin;
|
||||
totalAmount += schedule.Ordibehesht;
|
||||
totalAmount += schedule.Khordad;
|
||||
totalAmount += schedule.Tir;
|
||||
totalAmount += schedule.Mordad;
|
||||
totalAmount += schedule.Shahrivar;
|
||||
totalAmount += schedule.Mehr;
|
||||
totalAmount += schedule.Aban;
|
||||
totalAmount += schedule.Azar;
|
||||
totalAmount += schedule.Dey;
|
||||
totalAmount += schedule.Bahman;
|
||||
totalAmount += schedule.Esfand;
|
||||
|
||||
return totalAmount;
|
||||
}
|
||||
|
||||
|
||||
public ServiceResponse<RequestFromCollege> GetRequest(int scheduleId, int monthId)
|
||||
{
|
||||
var item = new ServiceResponse<RequestFromCollege>();
|
||||
try
|
||||
{
|
||||
item.SetData(_context.RequestsFromColleges.Where(r => r.ScheduleId == scheduleId && r.MonthId == monthId)
|
||||
.Include(i => i.Month)
|
||||
.SingleOrDefault());
|
||||
item.SetStatus(ResultStatus.Success);
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
item.SetException(ex);
|
||||
item.SetStatus(ResultStatus.Error);
|
||||
}
|
||||
return item;
|
||||
}
|
||||
|
||||
public float GetMonthAmountForScheduleCollege(int scheduleId, int monthId)
|
||||
{
|
||||
ScheduleOfCollege schedule = GetScheduleOfCollege(scheduleId).Data;
|
||||
|
||||
switch (monthId)
|
||||
{
|
||||
case 1:
|
||||
return schedule.Farvardin;
|
||||
case 2:
|
||||
return schedule.Ordibehesht;
|
||||
case 3:
|
||||
return schedule.Khordad;
|
||||
case 4:
|
||||
return schedule.Tir;
|
||||
case 5:
|
||||
return schedule.Mordad;
|
||||
case 6:
|
||||
return schedule.Shahrivar;
|
||||
case 7:
|
||||
return schedule.Mehr;
|
||||
case 8:
|
||||
return schedule.Aban;
|
||||
case 9:
|
||||
return schedule.Azar;
|
||||
case 10:
|
||||
return schedule.Dey;
|
||||
case 11:
|
||||
return schedule.Bahman;
|
||||
case 12:
|
||||
return schedule.Esfand;
|
||||
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public float SumAmountOfMonth(ScheduleOfCollege schedule)
|
||||
{
|
||||
float amount = 0;
|
||||
amount += schedule.Farvardin;
|
||||
amount += schedule.Ordibehesht;
|
||||
amount += schedule.Khordad;
|
||||
amount += schedule.Tir;
|
||||
amount += schedule.Mordad;
|
||||
amount += schedule.Shahrivar;
|
||||
amount += schedule.Mehr;
|
||||
amount += schedule.Aban;
|
||||
amount += schedule.Azar;
|
||||
amount += schedule.Dey;
|
||||
amount += schedule.Bahman;
|
||||
amount += schedule.Esfand;
|
||||
return amount;
|
||||
|
||||
}
|
||||
|
||||
public IEnumerable<ScheduleOfCollegeByFilterViewModel> GetSchedulesOfCollege(int planId, int monthId, int ouId,int collegeId)
|
||||
{
|
||||
var schedules = _context.ScheduleOfColleges.Where( s =>
|
||||
s.YearId == planId &&
|
||||
s.ScheduleText.OuId == ouId &&
|
||||
s.CollegeId == collegeId
|
||||
).Include(s => s.ScheduleText).ToList();
|
||||
List<ScheduleOfCollegeByFilterViewModel> lst = new List<ScheduleOfCollegeByFilterViewModel>();
|
||||
foreach (var schedule in schedules)
|
||||
{
|
||||
|
||||
ScheduleOfCollegeByFilterViewModel item = new ScheduleOfCollegeByFilterViewModel();
|
||||
item.ScheduleTitle = schedule.ScheduleText;
|
||||
item.ScheduleId = schedule.ScheduleId;
|
||||
item.Plan = schedule.YearOfPlan;
|
||||
item.Month = _context.Months.Find(monthId);
|
||||
|
||||
RequestFromCollege itemReq = new RequestFromCollege();
|
||||
|
||||
|
||||
itemReq.AllocationAmount = GetMonthAmountForScheduleCollege(schedule.ScheduleId, monthId);
|
||||
var req = GetRequest(schedule.ScheduleId, monthId);
|
||||
itemReq.MonthId = monthId;
|
||||
itemReq.ScheduleId = schedule.ScheduleId;
|
||||
if(req.Data != null)
|
||||
{
|
||||
var request = req.Data;
|
||||
itemReq.RequestAmount = request.RequestAmount;
|
||||
itemReq.OU_Amount = request.OU_Amount;
|
||||
itemReq.ManagerAmount = request.ManagerAmount;
|
||||
itemReq.PaymentAmount = request.PaymentAmount;
|
||||
|
||||
itemReq = req.Data;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
itemReq.RequestAmount = 0;
|
||||
itemReq.OU_Amount = 0;
|
||||
itemReq.ManagerAmount = 0;
|
||||
itemReq.PaymentAmount = 0;
|
||||
}
|
||||
|
||||
|
||||
item.Request = itemReq;
|
||||
#region FillInfo
|
||||
|
||||
item.Target = schedule.TargetId.ToString();
|
||||
item.Strategy = schedule.GuidelineId.ToString();
|
||||
item.CostIndex = schedule.CostIndex;
|
||||
item.AppTypeId = schedule.AppTypeId;
|
||||
item.LevelId = schedule.LevelId;
|
||||
item.Priority = schedule.Priority;
|
||||
item.Importance = schedule.Importance;
|
||||
item.Quantity = schedule.Quantity;
|
||||
item.RevenueIndex = schedule.RevenueIndex;
|
||||
item.TestIndex = schedule.TestIndex;
|
||||
item.TotalCost = GetScheduleOfCollegeTotalAmount(schedule.ScheduleId);
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
lst.Add(item);
|
||||
}
|
||||
|
||||
return lst;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,263 @@
|
||||
using BlazorApp.Core.DTOs;
|
||||
using BlazorApp.DataLayer.Entities.Colleges.Schedule;
|
||||
using BlazorApp.DataLayer.Entities.OrganizationalUnits;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BlazorApp.Core.Services
|
||||
{
|
||||
public partial class OU_Service : IOU_Service
|
||||
{
|
||||
public ServiceResponse<ScheduleOfOU> CreateScheduleOfOu(ScheduleOfOU schedule)
|
||||
{
|
||||
var response = new ServiceResponse<ScheduleOfOU>();
|
||||
try
|
||||
{
|
||||
_context.SchedulesOf_OU.Add(schedule);
|
||||
_context.SaveChanges();
|
||||
response.SetStatus(ResultStatus.Success);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
response.SetException(ex);
|
||||
response.SetStatus(ResultStatus.Error);
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
public ServiceResponse<ScheduleOfOU> UpdateScheduleOfOu(ScheduleOfOU schedule)
|
||||
{
|
||||
|
||||
var response = new ServiceResponse<ScheduleOfOU>();
|
||||
try
|
||||
{
|
||||
var request = _context.RequestsFromUnits.Where(r => r.ScheduleId == schedule.ScheduleId).ToList();
|
||||
|
||||
foreach (var req in request)
|
||||
{
|
||||
for (int monthNumber = 1;monthNumber <= 12;monthNumber++)
|
||||
{
|
||||
if (req.MonthId == monthNumber)
|
||||
{
|
||||
req.AllocationAmount = ScheduleOuMountAmount(monthNumber, schedule);
|
||||
_context.RequestsFromUnits.Update(req);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
_context.SchedulesOf_OU.Update(schedule);
|
||||
_context.SaveChanges();
|
||||
response.SetStatus(ResultStatus.Success);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
response.SetException(ex);
|
||||
response.SetStatus(ResultStatus.Error);
|
||||
}
|
||||
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
float ScheduleOuMountAmount(int monthId, ScheduleOfOU ou)
|
||||
{
|
||||
switch (monthId)
|
||||
{
|
||||
case 1:
|
||||
return ou.Farvardin;
|
||||
break;
|
||||
case 2:
|
||||
return ou.Ordibehesht;
|
||||
break;
|
||||
case 3:
|
||||
return ou.Khordad;
|
||||
break;
|
||||
case 4:
|
||||
return ou.Tir;
|
||||
break;
|
||||
case 5:
|
||||
return ou.Mordad;
|
||||
break;
|
||||
case 6:
|
||||
return ou.Shahrivar;
|
||||
break;
|
||||
case 7:
|
||||
return ou.Mehr;
|
||||
break;
|
||||
case 8:
|
||||
return ou.Aban;
|
||||
break;
|
||||
case 9:
|
||||
return ou.Azar;
|
||||
break;
|
||||
case 10:
|
||||
return ou.Dey;
|
||||
break;
|
||||
case 11:
|
||||
return ou.Bahman;
|
||||
break;
|
||||
case 12:
|
||||
return ou.Esfand;
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public ServiceResponse<ScheduleOfOU> DeleteScheduleOfOu(ScheduleOfOU schedule)
|
||||
{
|
||||
var response = new ServiceResponse<ScheduleOfOU>();
|
||||
try
|
||||
{
|
||||
_context.SchedulesOf_OU.Remove(schedule);
|
||||
_context.SaveChanges();
|
||||
response.SetStatus(ResultStatus.Success);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
response.SetException(ex);
|
||||
response.SetStatus(ResultStatus.Error);
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
public ScheduleOfOU GetScheduleOfOu(int scheduleId)
|
||||
{
|
||||
return _context.SchedulesOf_OU.Where(i => i.ScheduleId == scheduleId)
|
||||
.Include(i => i.Target)
|
||||
.Include(i => i.Guideline)
|
||||
.Include(i => i.AppType)
|
||||
.Include(i => i.Level)
|
||||
.Include(i => i.ScheduleText)
|
||||
.SingleOrDefault();
|
||||
}
|
||||
|
||||
public RequestFromUnit GetRequest(int scheduleId, int monthId)
|
||||
{
|
||||
return _context.RequestsFromUnits.Where(i => i.ScheduleId == scheduleId && i.MonthId == monthId).SingleOrDefault();
|
||||
}
|
||||
|
||||
public float GetMonthAmountForScheduleOu(int scheduleId, int monthId)
|
||||
{
|
||||
ScheduleOfOU schedule = GetScheduleOfOu(scheduleId);
|
||||
|
||||
switch (monthId)
|
||||
{
|
||||
case 1:
|
||||
return schedule.Farvardin;
|
||||
case 2:
|
||||
return schedule.Ordibehesht;
|
||||
case 3:
|
||||
return schedule.Khordad;
|
||||
case 4:
|
||||
return schedule.Tir;
|
||||
case 5:
|
||||
return schedule.Mordad;
|
||||
case 6:
|
||||
return schedule.Shahrivar;
|
||||
case 7:
|
||||
return schedule.Mehr;
|
||||
case 8:
|
||||
return schedule.Aban;
|
||||
case 9:
|
||||
return schedule.Azar;
|
||||
case 10:
|
||||
return schedule.Dey;
|
||||
case 11:
|
||||
return schedule.Bahman;
|
||||
case 12:
|
||||
return schedule.Esfand;
|
||||
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public float GetScheduleOfOuTotalAmount(int scheduleId)
|
||||
{
|
||||
ScheduleOfOU schedule = GetScheduleOfOu(scheduleId);
|
||||
|
||||
float totalAmount = 0;
|
||||
totalAmount += schedule.Farvardin;
|
||||
totalAmount += schedule.Ordibehesht;
|
||||
totalAmount += schedule.Khordad;
|
||||
totalAmount += schedule.Tir;
|
||||
totalAmount += schedule.Mordad;
|
||||
totalAmount += schedule.Shahrivar;
|
||||
totalAmount += schedule.Mehr;
|
||||
totalAmount += schedule.Aban;
|
||||
totalAmount += schedule.Azar;
|
||||
totalAmount += schedule.Dey;
|
||||
totalAmount += schedule.Bahman;
|
||||
totalAmount += schedule.Esfand;
|
||||
|
||||
return totalAmount;
|
||||
}
|
||||
|
||||
public async Task<List<ScheduleOfOuByFilterViewModel>> GetSchedulesOfOu(int planId, int monthId, int ouId)
|
||||
{
|
||||
List<ScheduleOfOuByFilterViewModel> lst = new List<ScheduleOfOuByFilterViewModel>();
|
||||
|
||||
|
||||
var schedules = await _context.SchedulesOf_OU.Where(s =>
|
||||
s.YearId == planId &&
|
||||
s.OU_Id == ouId
|
||||
).ToListAsync();
|
||||
|
||||
foreach (var schedule in schedules)
|
||||
{
|
||||
ScheduleOfOuByFilterViewModel item = new ScheduleOfOuByFilterViewModel();
|
||||
item.ScheduleTitle = schedule.ScheduleText;
|
||||
item.ScheduleId = schedule.ScheduleId;
|
||||
item.Plan = schedule.YearOfPlan;
|
||||
item.Month = _context.Months.Find(monthId);
|
||||
|
||||
RequestFromUnit Request = new RequestFromUnit();
|
||||
Request.AllocationAmount = GetMonthAmountForScheduleOu(schedule.ScheduleId,monthId);
|
||||
Request.MonthId = monthId;
|
||||
Request.ScheduleId = schedule.ScheduleId;
|
||||
var req = GetRequest(schedule.ScheduleId,monthId);
|
||||
|
||||
if(req != null)
|
||||
{
|
||||
Request = req;
|
||||
}
|
||||
else
|
||||
{
|
||||
Request.RequestAmount = 0;
|
||||
Request.ManagerAmount = 0;
|
||||
Request.PaymentAmount = 0;
|
||||
}
|
||||
|
||||
item.Request = Request;
|
||||
|
||||
#region FillInfo
|
||||
|
||||
item.Target = schedule.TargetId.ToString();
|
||||
item.Strategy = schedule.GuidelineId.ToString();
|
||||
item.CostIndex = schedule.CostIndex;
|
||||
item.AppTypeId = schedule.AppTypeId;
|
||||
item.LevelId = schedule.LevelId;
|
||||
item.Priority = schedule.Priority;
|
||||
item.Importance = schedule.Importance;
|
||||
item.Quantity = schedule.Quantity;
|
||||
item.RevenueIndex = schedule.RevenueIndex;
|
||||
item.TestIndex = schedule.TestIndex;
|
||||
item.TotalCost = GetScheduleOfOuTotalAmount(schedule.ScheduleId);
|
||||
|
||||
#endregion
|
||||
|
||||
lst.Add(item);
|
||||
}
|
||||
|
||||
return lst;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using BlazorApp.DataLayer.Entities.OrganizationalUnits;
|
||||
|
||||
namespace BlazorApp.Core.Services
|
||||
{
|
||||
public partial class OU_Service:IOU_Service
|
||||
{
|
||||
public List<ScheduleText> GetAllScheduleTitle(int ouId)
|
||||
{
|
||||
OrganizationalUnit OU = GetOrganizationalUnit(ouId);
|
||||
return OU.ScheduleTitles.ToList();
|
||||
|
||||
}
|
||||
|
||||
public ServiceResponse<ScheduleText> UpdateScheduleTitle(ScheduleText scheduleTitle)
|
||||
{
|
||||
var item = new ServiceResponse<ScheduleText>();
|
||||
try
|
||||
{
|
||||
_context.ScheduleText.Update(scheduleTitle);
|
||||
_context.SaveChanges();
|
||||
item.SetData(scheduleTitle);
|
||||
item.SetStatus(ResultStatus.Success);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
item.SetException(ex);
|
||||
item.SetData(scheduleTitle);
|
||||
item.SetStatus(ResultStatus.Error);
|
||||
}
|
||||
return item;
|
||||
}
|
||||
|
||||
public ServiceResponse<ScheduleText> CreateScheduleTitle(ScheduleText scheduleTitle)
|
||||
{
|
||||
var item = new ServiceResponse<ScheduleText>();
|
||||
try
|
||||
{
|
||||
_context.ScheduleText.Add(scheduleTitle);
|
||||
_context.SaveChanges();
|
||||
item.SetData(scheduleTitle);
|
||||
item.SetStatus(ResultStatus.Success);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
item.SetException(ex);
|
||||
item.SetData(scheduleTitle);
|
||||
item.SetStatus(ResultStatus.Error);
|
||||
}
|
||||
return item;
|
||||
}
|
||||
|
||||
public ServiceResponse<ScheduleText> DeleteScheduleTitle(ScheduleText scheduleTitle)
|
||||
{
|
||||
var item = new ServiceResponse<ScheduleText>();
|
||||
try
|
||||
{
|
||||
_context.ScheduleText.Remove(scheduleTitle);
|
||||
_context.SaveChanges();
|
||||
item.SetData(scheduleTitle);
|
||||
item.SetStatus(ResultStatus.Success);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
item.SetException(ex);
|
||||
item.SetData(scheduleTitle);
|
||||
item.SetStatus(ResultStatus.Error);
|
||||
}
|
||||
return item;
|
||||
}
|
||||
|
||||
public ServiceResponse<ScheduleText> GetScheduleTitleById(int scheduleTitleId)
|
||||
{
|
||||
var item = new ServiceResponse<ScheduleText>();
|
||||
try
|
||||
{
|
||||
item.SetData(_context.ScheduleText.Find(scheduleTitleId));
|
||||
item.SetStatus(ResultStatus.Success);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
item.SetException(ex);
|
||||
item.SetData(null);
|
||||
item.SetStatus(ResultStatus.Error);
|
||||
}
|
||||
return item;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
using BlazorApp.DataLayer.Entities.Users;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BlazorApp.Core.Services
|
||||
{
|
||||
public partial class UserService:IUserService
|
||||
{
|
||||
public List<ServiceLocationOfUser> GetAllServiceLocations()
|
||||
{
|
||||
return _context.ServiceLocationOfUsers.ToList();
|
||||
}
|
||||
|
||||
public ServiceResponse<ServiceLocationOfUser> CreateServiceLocation(ServiceLocationOfUser serviceLocation)
|
||||
{
|
||||
var item = new ServiceResponse<ServiceLocationOfUser>();
|
||||
try
|
||||
{
|
||||
_context.ServiceLocationOfUsers.Add(serviceLocation);
|
||||
_context.SaveChanges();
|
||||
item.SetData(serviceLocation);
|
||||
item.SetStatus(ResultStatus.Success);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
item.SetException(ex);
|
||||
item.SetData(serviceLocation);
|
||||
item.SetStatus(ResultStatus.Error);
|
||||
}
|
||||
return item;
|
||||
}
|
||||
|
||||
public ServiceResponse<ServiceLocationOfUser> UpdateServiceLocation(ServiceLocationOfUser serviceLocation)
|
||||
{
|
||||
var item = new ServiceResponse<ServiceLocationOfUser>();
|
||||
try
|
||||
{
|
||||
_context.ServiceLocationOfUsers.Update(serviceLocation);
|
||||
_context.SaveChanges();
|
||||
item.SetData(serviceLocation);
|
||||
item.SetStatus(ResultStatus.Success);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
item.SetException(ex);
|
||||
item.SetData(serviceLocation);
|
||||
item.SetStatus(ResultStatus.Error);
|
||||
}
|
||||
return item;
|
||||
}
|
||||
|
||||
public ServiceResponse<ServiceLocationOfUser> DeleteServiceLocation(ServiceLocationOfUser serviceLocation)
|
||||
{
|
||||
var item = new ServiceResponse<ServiceLocationOfUser>();
|
||||
try
|
||||
{
|
||||
_context.ServiceLocationOfUsers.Remove(serviceLocation);
|
||||
_context.SaveChanges();
|
||||
item.SetData(serviceLocation);
|
||||
item.SetStatus(ResultStatus.Success);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
item.SetException(ex);
|
||||
item.SetData(serviceLocation);
|
||||
item.SetStatus(ResultStatus.Error);
|
||||
}
|
||||
return item;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,110 @@
|
||||
using BlazorApp.DataLayer.Context;
|
||||
using BlazorApp.DataLayer.Entities.Targets;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BlazorApp.Core.Services
|
||||
{
|
||||
public class TargetService : ITargetService
|
||||
{
|
||||
private BPOB_Context _contxt;
|
||||
public TargetService(BPOB_Context context)
|
||||
{
|
||||
_contxt = context;
|
||||
}
|
||||
|
||||
public ServiceResponse<Target> CreateTarget(Target target)
|
||||
{
|
||||
var item = new ServiceResponse<Target>();
|
||||
try
|
||||
{
|
||||
if(_contxt.Targets.Any(t => t.TargetId == target.TargetId))
|
||||
{
|
||||
item.SetData(target);
|
||||
item.SetStatus(ResultStatus.ConflictIdMission);
|
||||
return item;
|
||||
}
|
||||
|
||||
_contxt.Targets.Add(target);
|
||||
_contxt.SaveChanges();
|
||||
item.SetData(target);
|
||||
item.SetStatus(ResultStatus.Success);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
item.SetException(ex);
|
||||
item.SetData(target);
|
||||
item.SetStatus(ResultStatus.Error);
|
||||
}
|
||||
return item;
|
||||
}
|
||||
|
||||
public ServiceResponse<Target> DeleteTarget(Target target)
|
||||
{
|
||||
var item = new ServiceResponse<Target>();
|
||||
try
|
||||
{
|
||||
_contxt.Targets.Remove(target);
|
||||
_contxt.SaveChanges();
|
||||
item.SetData(target);
|
||||
item.SetStatus(ResultStatus.Success);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
item.SetException(ex);
|
||||
item.SetData(target);
|
||||
item.SetStatus(ResultStatus.Error);
|
||||
}
|
||||
return item;
|
||||
}
|
||||
|
||||
public List<Target> GetAllTargets()
|
||||
{
|
||||
return _contxt.Targets.ToList();
|
||||
}
|
||||
|
||||
public Target GetTarget(int targetId)
|
||||
{
|
||||
return _contxt.Targets.Find(targetId);
|
||||
}
|
||||
|
||||
public ServiceResponse<Target> UpdateTarget(Target target)
|
||||
{
|
||||
var item = new ServiceResponse<Target>();
|
||||
try
|
||||
{
|
||||
Target old = _contxt.Targets.Where(t => t.TargetId == target.TargetId).SingleOrDefault();
|
||||
|
||||
if(old != null)
|
||||
{
|
||||
if(target.Id != old.Id)
|
||||
{
|
||||
item.SetData(target);
|
||||
item.SetStatus(ResultStatus.ConflictIdMission);
|
||||
return item;
|
||||
}
|
||||
}
|
||||
|
||||
_contxt.Targets.Update(target);
|
||||
_contxt.SaveChanges();
|
||||
item.SetData(target);
|
||||
item.SetStatus(ResultStatus.Success);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
item.SetException(ex);
|
||||
item.SetData(target);
|
||||
item.SetStatus(ResultStatus.Error);
|
||||
}
|
||||
return item;
|
||||
}
|
||||
|
||||
public List<Target> GetTargetsOfGuideline(int guidelineId)
|
||||
{
|
||||
return _contxt.RelationTargetAndGuidelines.Where(r => r.GuidelineId == guidelineId).Select(r => r.Target).ToList();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,173 @@
|
||||
using BlazorApp.DataLayer.Context;
|
||||
using BlazorApp.DataLayer.Entities.Users;
|
||||
using Microsoft.AspNetCore.Components.Forms;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BlazorApp.Core.Services
|
||||
{
|
||||
public partial class UserService : IUserService
|
||||
{
|
||||
private BPOB_Context _context;
|
||||
public UserService(BPOB_Context context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
public ServiceResponse<User> CreateUser(User user)
|
||||
{
|
||||
var item = new ServiceResponse<User>();
|
||||
try
|
||||
{
|
||||
if(UseAlreadyUserName(user))
|
||||
{
|
||||
item.SetStatus(ResultStatus.ConflictUserName);
|
||||
return item;
|
||||
}
|
||||
_context.Users.Add(user);
|
||||
_context.SaveChanges();
|
||||
item.SetData(user);
|
||||
item.SetStatus(ResultStatus.Success);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
item.SetException(ex);
|
||||
item.SetData(user);
|
||||
item.SetStatus(ResultStatus.Error);
|
||||
}
|
||||
return item;
|
||||
}
|
||||
|
||||
bool UseAlreadyUserName(User user)
|
||||
{
|
||||
return _context.Users.Any(u => u.UserName == user.UserName && u.UserId != user.UserId);
|
||||
}
|
||||
|
||||
public ServiceResponse<User> DeleteUser(User user)
|
||||
{
|
||||
var item = new ServiceResponse<User>();
|
||||
try
|
||||
{
|
||||
_context.Users.Remove(user);
|
||||
_context.SaveChanges();
|
||||
item.SetData(user);
|
||||
item.SetStatus(ResultStatus.Success);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
item.SetException(ex);
|
||||
item.SetData(user);
|
||||
item.SetStatus(ResultStatus.Error);
|
||||
}
|
||||
return item;
|
||||
}
|
||||
|
||||
public List<User> GetAllUsers()
|
||||
{
|
||||
return _context.Users.ToList();
|
||||
}
|
||||
|
||||
public ServiceResponse<User> UpdateUser(User user)
|
||||
{
|
||||
var item = new ServiceResponse<User>();
|
||||
try
|
||||
{
|
||||
_context.Users.Update(user);
|
||||
_context.SaveChanges();
|
||||
item.SetData(user);
|
||||
item.SetStatus(ResultStatus.Success);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
item.SetException(ex);
|
||||
item.SetData(user);
|
||||
item.SetStatus(ResultStatus.Error);
|
||||
}
|
||||
return item;
|
||||
}
|
||||
|
||||
|
||||
public async Task<ServiceResponse<string>> SetAvatar(InputFileChangeEventArgs file)
|
||||
{
|
||||
string def = "Default.png";
|
||||
var item = new ServiceResponse<string>();
|
||||
try
|
||||
{
|
||||
string ex = Path.GetExtension(file.File.Name).ToLower();
|
||||
if(ex != ".png" && ex != ".jpeg" && ex != ".gif" && ex != ".jpg")
|
||||
{
|
||||
item.SetData(def);
|
||||
item.SetStatus(ResultStatus.InvalidFormat);
|
||||
return item;
|
||||
}
|
||||
string newName = NameGenerator.GenerateUniqCode() + ex;
|
||||
var path = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot", "UserImages", newName);
|
||||
var m = await Set(path,file);
|
||||
|
||||
item.SetData(newName);
|
||||
item.SetStatus(ResultStatus.Success);
|
||||
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
item.SetData(def);
|
||||
item.SetStatus(ResultStatus.Error);
|
||||
item.SetException(ex);
|
||||
}
|
||||
return item;
|
||||
}
|
||||
|
||||
private async Task<bool> Set(string path , InputFileChangeEventArgs e)
|
||||
{
|
||||
await using FileStream fs = new(path, FileMode.Create);
|
||||
await e.File.OpenReadStream().CopyToAsync(fs);
|
||||
return true;
|
||||
}
|
||||
|
||||
public ServiceResponse<bool> RemoveAvatar(string imgName)
|
||||
{
|
||||
var item = new ServiceResponse<bool>();
|
||||
try
|
||||
{
|
||||
var path = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot", "UserImages", imgName);
|
||||
if (File.Exists(path))
|
||||
{
|
||||
if(imgName != "Default.png")
|
||||
{
|
||||
File.Delete(path);
|
||||
}
|
||||
item.SetData(true);
|
||||
item.SetStatus(ResultStatus.Success);
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
item.SetException(ex);
|
||||
item.SetData(false);
|
||||
item.SetStatus(ResultStatus.Error);
|
||||
}
|
||||
return item;
|
||||
}
|
||||
|
||||
public User GetUserById(int userId)
|
||||
{
|
||||
return _context.Users.Find(userId);
|
||||
}
|
||||
|
||||
public User GetUserByUserName(string userName)
|
||||
{
|
||||
try
|
||||
{
|
||||
return _context.Users.SingleOrDefault(u => u.UserName == userName);
|
||||
}
|
||||
catch
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
using BlazorApp.DataLayer.Entities.Vision;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using BlazorApp.DataLayer.Context;
|
||||
|
||||
namespace BlazorApp.Core.Services
|
||||
{
|
||||
public class VisionService : IVisionService
|
||||
{
|
||||
private BPOB_Context _context;
|
||||
public VisionService(BPOB_Context context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
public ServiceResponse<Vision> CreateVision(Vision vision)
|
||||
{
|
||||
var item = new ServiceResponse<Vision>();
|
||||
try
|
||||
{
|
||||
_context.Visions.Add(vision);
|
||||
_context.SaveChanges();
|
||||
item.SetData(vision);
|
||||
item.SetStatus(ResultStatus.Success);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
item.SetData(vision);
|
||||
item.SetStatus(ResultStatus.Error);
|
||||
item.SetException(ex);
|
||||
}
|
||||
return item;
|
||||
}
|
||||
|
||||
public ServiceResponse<Vision> DeleteVision(Vision vision)
|
||||
{
|
||||
var item = new ServiceResponse<Vision>();
|
||||
try
|
||||
{
|
||||
_context.Visions.Remove(vision);
|
||||
_context.SaveChanges();
|
||||
item.SetData(vision);
|
||||
item.SetStatus(ResultStatus.Success);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
item.SetException(ex);
|
||||
item.SetData(vision);
|
||||
item.SetStatus(ResultStatus.Error);
|
||||
}
|
||||
return item;
|
||||
}
|
||||
|
||||
public List<Vision> GetAllVisions()
|
||||
{
|
||||
return _context.Visions.ToList();
|
||||
}
|
||||
|
||||
public ServiceResponse<Vision> UpdateVision(Vision vision)
|
||||
{
|
||||
var item = new ServiceResponse<Vision>();
|
||||
try
|
||||
{
|
||||
_context.Visions.Update(vision);
|
||||
_context.SaveChanges();
|
||||
item.SetData(vision);
|
||||
item.SetStatus(ResultStatus.Success);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
item.SetException(ex);
|
||||
item.SetData(vision);
|
||||
item.SetStatus(ResultStatus.Error);
|
||||
}
|
||||
return item;
|
||||
}
|
||||
|
||||
public Vision GetVision(int visionId)
|
||||
{
|
||||
return _context.Visions.Find(visionId);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,214 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using BlazorApp.DataLayer.Entities;
|
||||
using BlazorApp.DataLayer.Context;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace BlazorApp.Core.Services
|
||||
{
|
||||
public class YearOfPlanService : IYearOfPlanService
|
||||
{
|
||||
private BPOB_Context _context;
|
||||
public YearOfPlanService(BPOB_Context context)
|
||||
{
|
||||
_context = context; ;
|
||||
}
|
||||
|
||||
public ServiceResponse<List<YearOfPlan>> GetAllPlans()
|
||||
{
|
||||
var item = new ServiceResponse<List<YearOfPlan>>();
|
||||
|
||||
try
|
||||
{
|
||||
item.SetData(_context.YearOfPlants.ToList());
|
||||
item.Status = ResultStatus.Success;
|
||||
item.SetMessage(PanelManager.ResourceManager.GetString(ResultStatus.Success.ToString()));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
item.Status = ResultStatus.Error;
|
||||
item.SetMessage(PanelManager.ResourceManager.GetString(ResultStatus.Error.ToString()));
|
||||
item.SetException(ex);
|
||||
}
|
||||
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
public ServiceResponse<List<YearOfPlan>> GetShowPlans()
|
||||
{
|
||||
var item = new ServiceResponse<List<YearOfPlan>>();
|
||||
|
||||
try
|
||||
{
|
||||
item.SetData(_context.YearOfPlants.Where(p => p.Hidden != true).ToList());
|
||||
item.Status = ResultStatus.Success;
|
||||
item.SetMessage(PanelManager.ResourceManager.GetString(ResultStatus.Success.ToString()));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
item.Status = ResultStatus.Error;
|
||||
item.SetMessage(PanelManager.ResourceManager.GetString(ResultStatus.Error.ToString()));
|
||||
item.SetException(ex);
|
||||
}
|
||||
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
public ServiceResponse<YearOfPlan> GetPlanById(int planId)
|
||||
{
|
||||
var item = new ServiceResponse<YearOfPlan>();
|
||||
|
||||
try
|
||||
{
|
||||
item.SetData(_context.YearOfPlants.Find(planId));
|
||||
item.Status = ResultStatus.Success;
|
||||
item.SetMessage(PanelManager.ResourceManager.GetString(ResultStatus.Success.ToString()));
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
item.Status = ResultStatus.Error;
|
||||
item.SetMessage(PanelManager.ResourceManager.GetString(ResultStatus.Error.ToString()));
|
||||
item.SetException(ex);
|
||||
}
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
public async Task<ServiceResponse<YearOfPlan>> CreatePlan(YearOfPlan plan)
|
||||
{
|
||||
var item = new ServiceResponse<YearOfPlan>();
|
||||
try
|
||||
{
|
||||
await _context.YearOfPlants.AddAsync(plan);
|
||||
await _context.SaveChangesAsync();
|
||||
item.SetData(plan);
|
||||
item.Status = ResultStatus.Success;
|
||||
item.SetMessage(PanelManager.ResourceManager.GetString(ResultStatus.Success.ToString()));
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
item.SetData(plan);
|
||||
item.Status = ResultStatus.Error;
|
||||
item.SetMessage(PanelManager.ResourceManager.GetString(ResultStatus.Error.ToString()));
|
||||
item.SetException(ex);
|
||||
}
|
||||
return item;
|
||||
}
|
||||
|
||||
public ServiceResponse<YearOfPlan> DeletePlan(YearOfPlan plan)
|
||||
{
|
||||
var item = new ServiceResponse<YearOfPlan>();
|
||||
try
|
||||
{
|
||||
_context.YearOfPlants.Remove(plan);
|
||||
var validmonths = _context.ValidMonths.Where(v => v.YearId == plan.YearId);
|
||||
_context.ValidMonths.RemoveRange(validmonths);
|
||||
_context.SaveChanges();
|
||||
item.SetData(plan);
|
||||
item.Status = ResultStatus.Success;
|
||||
item.SetMessage(PanelManager.ResourceManager.GetString(ResultStatus.Success.ToString()));
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
item.SetData(plan);
|
||||
item.Status = ResultStatus.Error;
|
||||
item.SetMessage(PanelManager.ResourceManager.GetString(ResultStatus.Error.ToString()));
|
||||
item.SetException(ex);
|
||||
}
|
||||
return item;
|
||||
}
|
||||
|
||||
public ServiceResponse<YearOfPlan> DeletePlan(int planId)
|
||||
{
|
||||
var item = new ServiceResponse<YearOfPlan>();
|
||||
YearOfPlan plan = new YearOfPlan();
|
||||
try
|
||||
{
|
||||
plan = GetPlanById(planId).Data;
|
||||
item.SetData(DeletePlan(plan).Data);
|
||||
item.Status = ResultStatus.Success;
|
||||
item.SetMessage(PanelManager.ResourceManager.GetString(ResultStatus.Success.ToString()));
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
item.SetData(plan);
|
||||
item.Status = ResultStatus.Error;
|
||||
item.SetMessage(PanelManager.ResourceManager.GetString(ResultStatus.Error.ToString()));
|
||||
item.SetException(ex);
|
||||
}
|
||||
return item;
|
||||
}
|
||||
|
||||
public ServiceResponse<YearOfPlan> UpdatePlan(YearOfPlan plan)
|
||||
{
|
||||
var item = new ServiceResponse<YearOfPlan>();
|
||||
try
|
||||
{
|
||||
_context.YearOfPlants.Update(plan);
|
||||
_context.SaveChanges();
|
||||
item.SetData(plan);
|
||||
item.Status = ResultStatus.Success;
|
||||
item.SetMessage(PanelManager.ResourceManager.GetString(ResultStatus.Success.ToString()));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
item.SetData(plan);
|
||||
item.SetException(ex);
|
||||
item.Status = ResultStatus.Error;
|
||||
item.SetMessage(PanelManager.ResourceManager.GetString(ResultStatus.Error.ToString()));
|
||||
}
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
public int GetRequestCollegeCount(int plandId,int unitId)
|
||||
{
|
||||
return _context.RequestsFromColleges.Where(r => r.Schedule.ScheduleText.OU.OU_Id == unitId && r.Schedule.YearId == plandId).Count();
|
||||
}
|
||||
|
||||
public List<ValidMonth> GetValidMonthsOfPlan(int planId)
|
||||
{
|
||||
return _context.ValidMonths.Where(v => v.YearId == planId).ToList();
|
||||
}
|
||||
|
||||
public ServiceResponse<YearOfPlan> UpdatePlan(YearOfPlan plan, List<ValidMonth> months)
|
||||
{
|
||||
ServiceResponse<YearOfPlan> item = new ServiceResponse<YearOfPlan>();
|
||||
try
|
||||
{
|
||||
var resultOne = UpdatePlan(plan);
|
||||
if (resultOne.Status == ResultStatus.Success)
|
||||
{
|
||||
var items = _context.ValidMonths.Where(v => v.YearId == plan.YearId).ToList();
|
||||
_context.ValidMonths.RemoveRange(items);
|
||||
foreach (var month in months)
|
||||
{
|
||||
var validMonth = new ValidMonth();
|
||||
validMonth.MonthId = month.MonthId;
|
||||
validMonth.YearId = plan.YearId;
|
||||
_context.ValidMonths.Add(validMonth);
|
||||
}
|
||||
_context.SaveChanges();
|
||||
item.SetData(plan);
|
||||
item.SetStatus(ResultStatus.Success);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
item.SetData(plan);
|
||||
item.SetStatus(ResultStatus.Error);
|
||||
item.SetException(ex);
|
||||
}
|
||||
return item;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
using Microsoft.AspNetCore.Mvc.Filters;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BlazorApp.Core.Tool
|
||||
{
|
||||
public class ActionFilterCustomAttribute:ActionFilterAttribute
|
||||
{
|
||||
public override void OnActionExecuting(ActionExecutingContext context)
|
||||
{
|
||||
var result = context.HttpContext.User;
|
||||
base.OnActionExecuting(context);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BlazorApp.Core.Tool
|
||||
{
|
||||
public class NumberResponse<T> : ServiceResponse<T>
|
||||
{
|
||||
public int OtherNumber { get; set; }
|
||||
|
||||
public void SetNumber(int number)
|
||||
{
|
||||
OtherNumber = number;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
namespace BlazorApp.Core
|
||||
{
|
||||
public enum ResultStatus
|
||||
{
|
||||
/// <summary>
|
||||
/// با موفقیت انجام شد
|
||||
/// </summary>
|
||||
Success = 1,
|
||||
/// <summary>
|
||||
/// عملیات نامشخص
|
||||
/// </summary>
|
||||
UnKnow = 0,
|
||||
/// <summary>
|
||||
/// عملیات با خطا مواجه شد
|
||||
/// </summary>
|
||||
Error = -1,
|
||||
/// <summary>
|
||||
/// را پر کنید{0}دیتا کامل نمیباشد لطفا
|
||||
/// </summary>
|
||||
DataNotComplete = -2,
|
||||
/// <summary>
|
||||
/// شناسه تکراری میباشد
|
||||
/// </summary>
|
||||
ConflictIdMission = -3,
|
||||
/// <summary>
|
||||
/// نام کاربری تکراری میباشد
|
||||
/// </summary>
|
||||
ConflictUserName = -4,
|
||||
/// <summary>
|
||||
/// فرمت نامعتبر میباشد
|
||||
/// </summary>
|
||||
InvalidFormat = -5,
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
namespace BlazorApp.Core
|
||||
{
|
||||
public class ServiceResponse<T>
|
||||
{
|
||||
public T Data { get; set; }
|
||||
public string Message { get; set; }
|
||||
public ResultStatus Status { get; set; }
|
||||
|
||||
public Exception ErrorException { get; set; }
|
||||
|
||||
public void SetData(T param)
|
||||
{
|
||||
Data = param;
|
||||
}
|
||||
|
||||
public void SetStatus(ResultStatus result)
|
||||
{
|
||||
Status = result;
|
||||
string var = result.ToString();
|
||||
if(Message == "")
|
||||
{
|
||||
Message = PanelManager.ResourceManager.GetString(result.ToString());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void SetStatus(bool result)
|
||||
{
|
||||
if(result == true)
|
||||
{
|
||||
Status = ResultStatus.Success;
|
||||
}
|
||||
else
|
||||
{
|
||||
Status = ResultStatus.Error;
|
||||
}
|
||||
//Status = result;
|
||||
//string var = result.ToString();
|
||||
if(Message == "")
|
||||
{
|
||||
Message = PanelManager.ResourceManager.GetString(result.ToString());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void AddMessage(string msg)
|
||||
{
|
||||
Message += msg + "\r\n";
|
||||
}
|
||||
|
||||
public static implicit operator ServiceResponse<T>(T data)
|
||||
{
|
||||
return new ServiceResponse<T>()
|
||||
{
|
||||
Data = data,
|
||||
Message = "با موفقیت انجام شد",
|
||||
Status = ResultStatus.Success,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
public void SetMessage(string param)
|
||||
{
|
||||
AddMessage(param);
|
||||
//Message = param;
|
||||
}
|
||||
|
||||
public void SetException(Exception ex)
|
||||
{
|
||||
ErrorException = ex;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class ServiceResponseByNumber<T> : ServiceResponse<T>
|
||||
{
|
||||
public int Number { get; set; }
|
||||
|
||||
public void SetNumber(int number)
|
||||
{
|
||||
Number = number;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
using BlazorApp.Core.Services;
|
||||
using BlazorApp.Core.Services.Interface;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BlazorApp.Core.UnitOfWorks
|
||||
{
|
||||
public interface IUnitOfWork:IDisposable
|
||||
{
|
||||
IPersonnelServiceTwo PersonnelService { get; }
|
||||
|
||||
ICollegeService CollegeService { get; }
|
||||
|
||||
ITalentFrm_IndividualProfileService TalentFrm_IndividualProfileService { get; }
|
||||
|
||||
int Save();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
using BlazorApp.Core.Services;
|
||||
using BlazorApp.Core.Services.Interface;
|
||||
using BlazorApp.Core.Services.Modern.TalentSearch;
|
||||
using BlazorApp.DataLayer.Context;
|
||||
using BlazorApp.DataLayer.Migrations;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BlazorApp.Core.UnitOfWorks
|
||||
{
|
||||
public class UnitOfWork : IUnitOfWork
|
||||
{
|
||||
private readonly BPOB_Context context;
|
||||
public UnitOfWork(BPOB_Context context)
|
||||
{
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
private IPersonnelServiceTwo personnelService;
|
||||
public IPersonnelServiceTwo PersonnelService
|
||||
{
|
||||
get
|
||||
{
|
||||
if(personnelService == null)
|
||||
{
|
||||
personnelService = new Services.PersonnelServiceTwo(context);
|
||||
}
|
||||
return personnelService;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private ICollegeService collegeService;
|
||||
public ICollegeService CollegeService
|
||||
{
|
||||
get
|
||||
{
|
||||
if (collegeService == null)
|
||||
{
|
||||
collegeService = new Services.CollegeService(context);
|
||||
}
|
||||
return collegeService;
|
||||
}
|
||||
}
|
||||
|
||||
private ITalentFrm_IndividualProfileService talentFrm_Service;
|
||||
public ITalentFrm_IndividualProfileService TalentFrm_IndividualProfileService
|
||||
{
|
||||
get
|
||||
{
|
||||
if (talentFrm_Service == null)
|
||||
{
|
||||
talentFrm_Service = new TalentFrm_IndividualService(context);
|
||||
}
|
||||
return talentFrm_Service;
|
||||
}
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
context.Dispose();
|
||||
}
|
||||
|
||||
public int Save()
|
||||
{
|
||||
return context.SaveChanges();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
|
||||
namespace BlazorApp.Core.Utilities
|
||||
{
|
||||
public static class EnumExtensions
|
||||
{
|
||||
public static IEnumerable<T> GetEnumValues<T>(this T input) where T : struct
|
||||
{
|
||||
if (!typeof(T).IsEnum)
|
||||
throw new NotSupportedException();
|
||||
|
||||
return Enum.GetValues(input.GetType()).Cast<T>();
|
||||
}
|
||||
|
||||
public static IEnumerable<T> GetEnumFlags<T>(this T input) where T : struct
|
||||
{
|
||||
if (!typeof(T).IsEnum)
|
||||
throw new NotSupportedException();
|
||||
|
||||
foreach (var value in Enum.GetValues(input.GetType()))
|
||||
if ((input as Enum).HasFlag(value as Enum))
|
||||
yield return (T)value;
|
||||
}
|
||||
|
||||
public static string ToDisplay(this Enum value, DisplayProperty property = DisplayProperty.Name)
|
||||
{
|
||||
|
||||
var attribute = value.GetType().GetField(value.ToString())
|
||||
.GetCustomAttributes<DisplayAttribute>(false).FirstOrDefault();
|
||||
|
||||
if (attribute == null)
|
||||
return value.ToString();
|
||||
|
||||
var propValue = attribute.GetType().GetProperty(property.ToString()).GetValue(attribute, null);
|
||||
return propValue.ToString();
|
||||
}
|
||||
|
||||
public static Dictionary<int, string> ToDictionary(this Enum value)
|
||||
{
|
||||
return Enum.GetValues(value.GetType()).Cast<Enum>().ToDictionary(p => Convert.ToInt32(p), q => ToDisplay(q));
|
||||
}
|
||||
}
|
||||
|
||||
public enum DisplayProperty
|
||||
{
|
||||
Description,
|
||||
GroupName,
|
||||
Name,
|
||||
Prompt,
|
||||
ShortName,
|
||||
Order
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user