89 lines
2.9 KiB
C#
89 lines
2.9 KiB
C#
using AutoMapper;
|
|
using Complex.Application.AppCommon;
|
|
using Complex.Application.Complex;
|
|
using Complex.Common.Dto;
|
|
using Complex.Domain.Entities;
|
|
using Complex.EndPoint.Utility;
|
|
using Complex.EndPoint.ViewModel;
|
|
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
namespace Complex.EndPoint.Controllers
|
|
{
|
|
[ApiController]
|
|
[ApiVersion("1")]
|
|
[Route("api/v{version:apiVersion}/[controller]/[action]")]
|
|
//[Route("[controller]/[action]")]
|
|
[Authorize]
|
|
public class UnitController : Controller
|
|
{
|
|
private readonly IUnitService _unitService;
|
|
private IMapper _mapper;
|
|
|
|
public UnitController(IUnitService unitService, IMapper mapper)
|
|
{
|
|
_unitService = unitService;
|
|
_mapper = mapper;
|
|
}
|
|
|
|
[HttpPost]
|
|
public ResultDto<Guid> InsertUnit(UnitViewModel unit)
|
|
{
|
|
//var unitDto = new UnitDto
|
|
//{
|
|
// AreaMeter = unit.AreaMeter,
|
|
// ComplexId = unit.ComplexId,
|
|
// EmergencyTels = unit.EmergencyTels,
|
|
// Floor = unit.Floor,
|
|
// IsActive = unit.IsActive == true,
|
|
// LastPaymentDate = unit.LastPaymentDate,
|
|
// ManagerDescription = unit.ManagerDescription,
|
|
// ParkingAreaMeter = unit.ParkingAreaMeter,
|
|
// RemainingAmount = unit.RemainingAmount,
|
|
// OwnerId = unit.OwnerId,
|
|
// StateId = unit.StateId,
|
|
// YardMeter = unit.YardMeter,
|
|
// UnitId = unit.UnitId,
|
|
// TenantId = unit.TenantId,
|
|
//};
|
|
var unitDto = _mapper.Map<UnitDto>(unit);
|
|
return _unitService.InsertUnit(User.GetUserId(),unitDto);
|
|
}
|
|
/// <summary>
|
|
/// ویرایش توسط مدیر ساختمان
|
|
/// </summary>
|
|
/// <param name="unitDto"></param>
|
|
/// <returns></returns>
|
|
[HttpPost]
|
|
public ResultDto<bool> AdminEditUnit(UnitDto unitDto)
|
|
{
|
|
return _unitService.AdminEditUnit(User.GetUserId(), unitDto);
|
|
}
|
|
/// <summary>
|
|
/// ویرایش توسط مالک
|
|
/// </summary>
|
|
/// <param name="unitDto"></param>
|
|
/// <returns></returns>
|
|
[HttpPost]
|
|
public ResultDto<bool> OwnerEditUnit(UnitDto unitDto)
|
|
{
|
|
return _unitService.OwnerEditUnit(User.GetUserId(), unitDto);
|
|
}
|
|
/// <summary>
|
|
/// ویرایش توسط مستاجر
|
|
/// </summary>
|
|
/// <param name="unitDto"></param>
|
|
/// <returns></returns>
|
|
[HttpPost]
|
|
public ResultDto<bool> TenantEditUnit(UnitDto unitDto)
|
|
{
|
|
return _unitService.TenantEditUnit(User.GetUserId(), unitDto);
|
|
}
|
|
[HttpPost]
|
|
public ResultDto<List<UnitDto>> UnitList(UnitRequestList unitRequest)
|
|
{
|
|
return _unitService.UnitList(User.GetUserId(), unitRequest);
|
|
}
|
|
}
|
|
}
|