Move request demo api to separate market controller
This commit is contained in:
parent
aa1d5020f7
commit
dcd39db3b0
@ -1,19 +1,16 @@
|
|||||||
using System.Net;
|
using Marco.Pms.DataAccess.Data;
|
||||||
using Marco.Pms.DataAccess.Data;
|
|
||||||
using Marco.Pms.Model.Authentication;
|
using Marco.Pms.Model.Authentication;
|
||||||
using Marco.Pms.Model.Dtos;
|
using Marco.Pms.Model.Dtos;
|
||||||
using Marco.Pms.Model.Dtos.Util;
|
using Marco.Pms.Model.Dtos.Util;
|
||||||
using Marco.Pms.Model.Employees;
|
using Marco.Pms.Model.Employees;
|
||||||
using Marco.Pms.Model.Entitlements;
|
using Marco.Pms.Model.Entitlements;
|
||||||
using Marco.Pms.Model.Industries;
|
|
||||||
using Marco.Pms.Model.Mapper;
|
|
||||||
using Marco.Pms.Model.Utilities;
|
using Marco.Pms.Model.Utilities;
|
||||||
using MarcoBMS.Services.Helpers;
|
using MarcoBMS.Services.Helpers;
|
||||||
using MarcoBMS.Services.Service;
|
using MarcoBMS.Services.Service;
|
||||||
using Microsoft.AspNetCore.Identity;
|
using Microsoft.AspNetCore.Identity;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.VisualStudio.Web.CodeGenerators.Mvc.Templates.BlazorIdentity.Pages.Manage;
|
using System.Net;
|
||||||
|
|
||||||
namespace MarcoBMS.Services.Controllers
|
namespace MarcoBMS.Services.Controllers
|
||||||
{
|
{
|
||||||
@ -205,27 +202,8 @@ namespace MarcoBMS.Services.Controllers
|
|||||||
return Ok(ApiResponse<object>.SuccessResponse(result.Succeeded, "Password reset successfully.", 200));
|
return Ok(ApiResponse<object>.SuccessResponse(result.Succeeded, "Password reset successfully.", 200));
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost("inquiry")]
|
|
||||||
public async Task<IActionResult> RequestDemo([FromBody] InquiryDto inquiryDto)
|
|
||||||
{
|
|
||||||
Inquiries inquiry = inquiryDto.ToInquiriesFromInquiriesDto();
|
|
||||||
_context.Inquiries.Add(inquiry);
|
|
||||||
await _context.SaveChangesAsync();
|
|
||||||
|
|
||||||
Industry industry = await _context.Industries.FirstOrDefaultAsync(i => i.Id == inquiryDto.IndustryId) ?? new Industry();
|
|
||||||
if(industry != null && industry.Name != null)
|
|
||||||
{
|
|
||||||
InquiryEmailObject inquiryEmailObject = inquiryDto.ToInquiryEmailObjectFromInquiriesDto(industry.Name);
|
|
||||||
string emails = _configuration["Contact:Emails"]?? "";
|
|
||||||
List<string> result = emails
|
|
||||||
.Split(';', StringSplitOptions.RemoveEmptyEntries)
|
|
||||||
.Select(item => item.Trim())
|
|
||||||
.ToList();
|
|
||||||
await _emailSender.SendRequestDemoEmail(result, inquiryEmailObject);
|
|
||||||
return Ok(ApiResponse<object>.SuccessResponse(new {}, "Email sent.", 200));
|
|
||||||
}
|
|
||||||
return NotFound(ApiResponse<object>.ErrorResponse("Industry not found.", "Industry not found.", 404));
|
|
||||||
}
|
|
||||||
[HttpPost("sendmail")]
|
[HttpPost("sendmail")]
|
||||||
public async Task<IActionResult> SendEmail([FromBody] EmailDot emailDot)
|
public async Task<IActionResult> SendEmail([FromBody] EmailDot emailDot)
|
||||||
{
|
{
|
||||||
|
60
Marco.Pms.Services/Controllers/MarketController.cs
Normal file
60
Marco.Pms.Services/Controllers/MarketController.cs
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
using Marco.Pms.DataAccess.Data;
|
||||||
|
using Marco.Pms.Model.Dtos.Util;
|
||||||
|
using Marco.Pms.Model.Industries;
|
||||||
|
using Marco.Pms.Model.Mapper;
|
||||||
|
using Marco.Pms.Model.Utilities;
|
||||||
|
using MarcoBMS.Services.Helpers;
|
||||||
|
using MarcoBMS.Services.Service;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
|
namespace Marco.Pms.Services.Controllers
|
||||||
|
{
|
||||||
|
public class MarketController : ControllerBase
|
||||||
|
{
|
||||||
|
private readonly ApplicationDbContext _context;
|
||||||
|
private readonly UserHelper _userHelper;
|
||||||
|
private readonly IEmailSender _emailSender;
|
||||||
|
private readonly IConfiguration _configuration;
|
||||||
|
public MarketController(ApplicationDbContext context, UserHelper userHelper, RefreshTokenService refreshTokenService,
|
||||||
|
IEmailSender emailSender, IConfiguration configuration, EmployeeHelper employeeHelper)
|
||||||
|
{
|
||||||
|
_context = context;
|
||||||
|
_userHelper = userHelper;
|
||||||
|
_emailSender = emailSender;
|
||||||
|
_configuration = configuration;
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet]
|
||||||
|
[Route("industries")]
|
||||||
|
public async Task<IActionResult> GetIndustries()
|
||||||
|
{
|
||||||
|
var tenantId = _userHelper.GetTenantId();
|
||||||
|
var industries = await _context.Industries.ToListAsync();
|
||||||
|
|
||||||
|
return Ok(ApiResponse<object>.SuccessResponse(industries, "Success.", 200));
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost("inquiry")]
|
||||||
|
public async Task<IActionResult> RequestDemo([FromBody] InquiryDto inquiryDto)
|
||||||
|
{
|
||||||
|
Inquiries inquiry = inquiryDto.ToInquiriesFromInquiriesDto();
|
||||||
|
_context.Inquiries.Add(inquiry);
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
|
|
||||||
|
Industry industry = await _context.Industries.FirstOrDefaultAsync(i => i.Id == inquiryDto.IndustryId) ?? new Industry();
|
||||||
|
if (industry != null && industry.Name != null)
|
||||||
|
{
|
||||||
|
InquiryEmailObject inquiryEmailObject = inquiryDto.ToInquiryEmailObjectFromInquiriesDto(industry.Name);
|
||||||
|
string emails = _configuration["Contact:Emails"] ?? "";
|
||||||
|
List<string> result = emails
|
||||||
|
.Split(';', StringSplitOptions.RemoveEmptyEntries)
|
||||||
|
.Select(item => item.Trim())
|
||||||
|
.ToList();
|
||||||
|
await _emailSender.SendRequestDemoEmail(result, inquiryEmailObject);
|
||||||
|
return Ok(ApiResponse<object>.SuccessResponse(new { }, "Email sent.", 200));
|
||||||
|
}
|
||||||
|
return NotFound(ApiResponse<object>.ErrorResponse("Industry not found.", "Industry not found.", 404));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -64,8 +64,8 @@
|
|||||||
|
|
||||||
"ConnectionStrings": {
|
"ConnectionStrings": {
|
||||||
// "DefaultConnectionString": "Server=103.50.160.45;User ID=marcowvh_admin;Password=Marcoemp@123;Database=marcowvh_empattendanceci",
|
// "DefaultConnectionString": "Server=103.50.160.45;User ID=marcowvh_admin;Password=Marcoemp@123;Database=marcowvh_empattendanceci",
|
||||||
"DefaultConnectionString": "Server=localhost;port=3306;User ID=root;Password=root;Database=MarcoBMS2"
|
//"DefaultConnectionString": "Server=localhost;port=3306;User ID=root;Password=root;Database=MarcoBMS2"
|
||||||
//"DefaultConnectionString": "Server=147.93.98.152;User ID=devuser;Password=AppUser@123$;Database=MarcoBMS1"
|
"DefaultConnectionString": "Server=147.93.98.152;User ID=devuser;Password=AppUser@123$;Database=MarcoBMS1"
|
||||||
},
|
},
|
||||||
"AppSettings": {
|
"AppSettings": {
|
||||||
"WebFrontendUrl": "http://localhost:5173",
|
"WebFrontendUrl": "http://localhost:5173",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user