SmsSettings List , create, edit, delete
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
using _0_Framework.Application.Enums;
|
||||
using _0_Framework.Domain;
|
||||
using CompanyManagment.App.Contracts.SmsResult;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Company.Domain.SmsResultAgg;
|
||||
@@ -27,4 +28,25 @@ public interface ISmsSettingsRepository : IRepository<long, SmsSetting>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
Task RemoveItem(long id);
|
||||
|
||||
|
||||
#region ForApi
|
||||
|
||||
/// <summary>
|
||||
/// دریافت لیست پیامک های خودکار بر اساس نوع آن
|
||||
/// Api
|
||||
/// </summary>
|
||||
/// <param name="typeOfSmsSetting"></param>
|
||||
/// <returns></returns>
|
||||
Task<List<SmsSettingDto>> GetSmsSettingList(TypeOfSmsSetting typeOfSmsSetting);
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// دریافت اطلاعات تنظیمات پیامک جهت ویرایش
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
Task<SmsSettingDto> GetSmsSettingDataToEdit(long id);
|
||||
#endregion
|
||||
}
|
||||
@@ -60,3 +60,29 @@ public class SmsSettingViewModel
|
||||
/// </summary>
|
||||
public List<EditSmsSetting> EditSmsSettings { get; set; }
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// لیست تنظیمات پیامک خودکار
|
||||
/// </summary>
|
||||
public class SmsSettingDto
|
||||
{
|
||||
/// <summary>
|
||||
/// آی دی
|
||||
/// </summary>
|
||||
public long Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// عدد روز از ماه
|
||||
/// </summary>
|
||||
public int DayOfMonth { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// نمایش ساعت و دقیقه
|
||||
/// </summary>
|
||||
public string TimeOfDayDisplay { get; set; }
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -75,4 +75,31 @@ public interface ISmsSettingApplication
|
||||
/// <param name="command"></param>
|
||||
/// <returns></returns>
|
||||
Task<OperationResult> InstantSendBlockSms(List<BlockSmsListData> command);
|
||||
|
||||
|
||||
#region ForApi
|
||||
|
||||
/// <summary>
|
||||
/// دریافت لیست پیامک های خودکار بر اساس نوع آن
|
||||
/// Api
|
||||
/// </summary>
|
||||
/// <param name="typeOfSmsSetting"></param>
|
||||
/// <returns></returns>
|
||||
Task<List<SmsSettingDto>> GetSmsSettingList(TypeOfSmsSetting typeOfSmsSetting);
|
||||
|
||||
/// <summary>
|
||||
/// دریافت اطلاعات تنظیمات پیامک جهت ویرایش
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
Task<SmsSettingDto> GetSmsSettingDataToEdit(long id);
|
||||
|
||||
/// <summary>
|
||||
/// ویرایش تنظیمات پیامک
|
||||
/// </summary>
|
||||
/// <param name="command"></param>
|
||||
/// <returns></returns>
|
||||
Task<OperationResult> EditSmsSetting(SmsSettingDto command);
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -165,4 +165,57 @@ public class SmsSettingApplication : ISmsSettingApplication
|
||||
return op.Failed("موردی انتخاب نشده است");
|
||||
}
|
||||
}
|
||||
|
||||
#region ForApi
|
||||
|
||||
/// <summary>
|
||||
/// دریافت لیست پیامک های خودکار بر اساس نوع آن
|
||||
/// Api
|
||||
/// </summary>
|
||||
/// <param name="typeOfSmsSetting"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<List<SmsSettingDto>> GetSmsSettingList(TypeOfSmsSetting typeOfSmsSetting)
|
||||
{
|
||||
return await _smsSettingsRepository.GetSmsSettingList(typeOfSmsSetting);
|
||||
}
|
||||
|
||||
|
||||
public async Task<SmsSettingDto> GetSmsSettingDataToEdit(long id)
|
||||
{
|
||||
return await _smsSettingsRepository.GetSmsSettingDataToEdit(id);
|
||||
}
|
||||
|
||||
|
||||
public async Task<OperationResult> EditSmsSetting(SmsSettingDto command)
|
||||
{
|
||||
var op = new OperationResult();
|
||||
var editSmsSetting = _smsSettingsRepository.Get(command.Id);
|
||||
var timeSpan = new TimeSpan();
|
||||
if (string.IsNullOrWhiteSpace(command.TimeOfDayDisplay))
|
||||
return op.Failed("ساعت وارد نشده است");
|
||||
|
||||
try
|
||||
{
|
||||
timeSpan = TimeSpan.ParseExact(command.TimeOfDayDisplay, @"hh\:mm", null);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return op.Failed("فرمت ساعت اشتباه است");
|
||||
}
|
||||
|
||||
if (command.DayOfMonth < 1 || command.DayOfMonth > 31)
|
||||
{
|
||||
return op.Failed("عدد روز می بایست بین 1 تا 31 باشد");
|
||||
}
|
||||
|
||||
if (_smsSettingsRepository.Exists(x => x.DayOfMonth == command.DayOfMonth && x.TimeOfDay == timeSpan && x.TypeOfSmsSetting == editSmsSetting.TypeOfSmsSetting && x.id != command.Id))
|
||||
return op.Failed("رکورد ایجاد شده تکراری است");
|
||||
|
||||
|
||||
editSmsSetting.Edit(command.DayOfMonth, timeSpan);
|
||||
await _smsSettingsRepository.SaveChangesAsync();
|
||||
|
||||
return op.Succcedded();
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using _0_Framework.Application.Enums;
|
||||
using _0_Framework.InfraStructure;
|
||||
@@ -68,4 +69,48 @@ public class SmsSettingsRepository : RepositoryBase<long, SmsSetting>, ISmsSetti
|
||||
_context.SmsSettings.Remove(removeItem);
|
||||
await _context.SaveChangesAsync();
|
||||
}
|
||||
|
||||
|
||||
#region ForApi
|
||||
/// <summary>
|
||||
/// دریافت لیست پیامک های خودکار بر اساس نوع آن
|
||||
/// Api
|
||||
/// </summary>
|
||||
/// <param name="typeOfSmsSetting"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<List<SmsSettingDto>> GetSmsSettingList(TypeOfSmsSetting typeOfSmsSetting)
|
||||
{
|
||||
|
||||
var data = await _context.SmsSettings
|
||||
.Where(x => x.TypeOfSmsSetting == typeOfSmsSetting)
|
||||
.OrderBy(x => x.DayOfMonth).ThenBy(x => x.TimeOfDay)
|
||||
.Select(x =>
|
||||
new SmsSettingDto()
|
||||
{
|
||||
Id = x.id,
|
||||
DayOfMonth = x.DayOfMonth,
|
||||
TimeOfDayDisplay = x.TimeOfDay.ToString(@"hh\:mm")
|
||||
}).ToListAsync();
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
public async Task<SmsSettingDto> GetSmsSettingDataToEdit(long id)
|
||||
{
|
||||
var edit = new SmsSettingDto();
|
||||
var getItem = await _context.SmsSettings.FirstOrDefaultAsync(x => x.id == id);
|
||||
|
||||
if (getItem != null)
|
||||
{
|
||||
edit.Id = getItem.id;
|
||||
edit.TimeOfDayDisplay = getItem.TimeOfDay.ToString(@"hh\:mm");
|
||||
edit.DayOfMonth = getItem.DayOfMonth;
|
||||
|
||||
}
|
||||
|
||||
return edit;
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -1,4 +1,6 @@
|
||||
using _0_Framework.Application.Sms;
|
||||
using _0_Framework.Application;
|
||||
using _0_Framework.Application.Enums;
|
||||
using _0_Framework.Application.Sms;
|
||||
using CompanyManagment.App.Contracts.SmsResult;
|
||||
using CompanyManagment.App.Contracts.SmsResult.Dto;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
@@ -9,12 +11,14 @@ namespace ServiceHost.Areas.Admin.Controllers;
|
||||
public class SmsReportController : AdminBaseController
|
||||
{
|
||||
private readonly ISmsResultApplication _smsResultApplication;
|
||||
private readonly ISmsSettingApplication _smsSettingApplication;
|
||||
private readonly ISmsService _smsService;
|
||||
|
||||
public SmsReportController(ISmsResultApplication smsResultApplication, ISmsService smsService)
|
||||
public SmsReportController(ISmsResultApplication smsResultApplication, ISmsService smsService, ISmsSettingApplication smsSettingApplication)
|
||||
{
|
||||
_smsResultApplication = smsResultApplication;
|
||||
_smsService = smsService;
|
||||
_smsSettingApplication = smsSettingApplication;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -56,4 +60,171 @@ public class SmsReportController : AdminBaseController
|
||||
return result;
|
||||
}
|
||||
|
||||
//تنظیمات پیامک خودکار
|
||||
#region SmsSettings
|
||||
|
||||
/// <summary>
|
||||
/// لیست تنظیمات پیامک - یادآور
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet("ReminderSmsSettingList")]
|
||||
public async Task<List<SmsSettingDto>> ReminderSmsSettingList()
|
||||
{
|
||||
var result = await _smsSettingApplication.GetSmsSettingList(TypeOfSmsSetting.InstitutionContractDebtReminder);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// لیست تنظیمات پیامک - مسدودی
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet("BlockSmsSettingList")]
|
||||
public async Task<List<SmsSettingDto>> BlockSmsSettingList()
|
||||
{
|
||||
var result = await _smsSettingApplication.GetSmsSettingList(TypeOfSmsSetting.BlockContractingParty);
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// لیست تنظیمات پیامک - هشدار قضایی
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet("WarningSmsSettingList")]
|
||||
public async Task<List<SmsSettingDto>> WarningSmsSettingList()
|
||||
{
|
||||
var result = await _smsSettingApplication.GetSmsSettingList(TypeOfSmsSetting.Warning);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// لیست تنظیمات پیامک - اقدام قضایی
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet("LegalActionSmsSettingList")]
|
||||
public async Task<List<SmsSettingDto>> LegalActionSmsSettingList()
|
||||
{
|
||||
var result = await _smsSettingApplication.GetSmsSettingList(TypeOfSmsSetting.LegalAction);
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// لیست تنظیمات پیامک - تایید قراداد مالی
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet("ContractConfirmSmsSettingList")]
|
||||
public async Task<List<SmsSettingDto>> ContractConfirmSmsSettingList()
|
||||
{
|
||||
var result = await _smsSettingApplication.GetSmsSettingList(TypeOfSmsSetting.InstitutionContractConfirm);
|
||||
return result;
|
||||
}
|
||||
|
||||
//=====================Create=========================
|
||||
|
||||
/// <summary>
|
||||
/// ایجاد پیامک یادآور
|
||||
/// </summary>
|
||||
/// <param name="dayOfMonth"></param>
|
||||
/// <param name="timeOfDay"></param>
|
||||
/// <param name="typeOfSmsSetting"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("CreateReminderSmsSetting")]
|
||||
public async Task<ActionResult<OperationResult>> CreateReminderSmsSetting(int dayOfMonth, string timeOfDay)
|
||||
{
|
||||
var result = await _smsSettingApplication.CreateSmsSetting(dayOfMonth, timeOfDay, TypeOfSmsSetting.InstitutionContractDebtReminder);
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ایجاد پیامک مسدودی
|
||||
/// </summary>
|
||||
/// <param name="dayOfMonth"></param>
|
||||
/// <param name="timeOfDay"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("CreateBlockSmsSetting")]
|
||||
public async Task<ActionResult<OperationResult>> CreateBlockSmsSetting(int dayOfMonth, string timeOfDay)
|
||||
{
|
||||
var result = await _smsSettingApplication.CreateSmsSetting(dayOfMonth, timeOfDay, TypeOfSmsSetting.BlockContractingParty);
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ایجاد پیامک هشدار قضایی
|
||||
/// </summary>
|
||||
/// <param name="dayOfMonth"></param>
|
||||
/// <param name="timeOfDay"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("CreateWarningSmsSetting")]
|
||||
public async Task<ActionResult<OperationResult>> CreateWarningSmsSetting(int dayOfMonth, string timeOfDay)
|
||||
{
|
||||
var result = await _smsSettingApplication.CreateSmsSetting(dayOfMonth, timeOfDay, TypeOfSmsSetting.Warning);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// ایجاد پیامک اقدام قضایی
|
||||
/// </summary>
|
||||
/// <param name="dayOfMonth"></param>
|
||||
/// <param name="timeOfDay"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("CreateLegalActionSmsSetting")]
|
||||
public async Task<ActionResult<OperationResult>> CreateLegalActionSmsSetting(int dayOfMonth, string timeOfDay)
|
||||
{
|
||||
var result = await _smsSettingApplication.CreateSmsSetting(dayOfMonth, timeOfDay, TypeOfSmsSetting.LegalAction);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// ایجاد پیامک تایید قرارداد مالی
|
||||
/// </summary>
|
||||
/// <param name="dayOfMonth"></param>
|
||||
/// <param name="timeOfDay"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("CreateContractConfirmSmsSetting")]
|
||||
public async Task<ActionResult<OperationResult>> CreateContractConfirmSmsSetting(int dayOfMonth, string timeOfDay)
|
||||
{
|
||||
var result = await _smsSettingApplication.CreateSmsSetting(dayOfMonth, timeOfDay, TypeOfSmsSetting.InstitutionContractConfirm);
|
||||
return result;
|
||||
}
|
||||
//=====================Edit=========================
|
||||
|
||||
/// <summary>
|
||||
/// دریافت اطلاعات ویرایش تنظیمات پیامک
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("GetEditData")]
|
||||
public async Task<SmsSettingDto> GetEditData(long id)
|
||||
{
|
||||
return await _smsSettingApplication.GetSmsSettingDataToEdit(id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ویرایش تنظیمات پیامک
|
||||
/// </summary>
|
||||
/// <param name="command"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("EditSmsSetting")]
|
||||
public async Task<ActionResult<OperationResult>> EditSmsSetting(SmsSettingDto command)
|
||||
{
|
||||
var result =await _smsSettingApplication.EditSmsSetting(command);
|
||||
return result;
|
||||
}
|
||||
|
||||
//=====================Remove=========================
|
||||
|
||||
/// <summary>
|
||||
/// حذف تنظیمات پیامک
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
[HttpDelete]
|
||||
public async Task RemoveSmsSetting(long id)
|
||||
{
|
||||
await _smsSettingApplication.RemoveSetting(id);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
Reference in New Issue
Block a user