public async Task <bool> PutDefinitiveInscriptionProcessNup( [FromServices] DataContext context, [FromBody] InscriptionProcess model) { if (ModelState.IsValid) { var process = await context.InscriptionProcesses .Include(x => x.InscriptionFinancedEnterprise) .Include(y => y.InscriptionResourceTaker) .FirstOrDefaultAsync(x => x.InscriptionProcessId == model.InscriptionProcessId); if (model.NupProtocol != process.NupProtocol) { process.NupProtocol = model.NupProtocol; process.ModifiedOn = DateTime.Now; process.ModifiedBy = ""; AdjustTask(process); context.InscriptionProcessTaskLogs.Add(new InscriptionProcessTaskLog { InscriptionProcessId = process.InscriptionProcessId, ModifiedAt = DateTime.Now, ModifiedBy = model.ModifiedBy, Task = "insercaoNup", Value = process.NupProtocol }); EmailSenderInscription.SendEmail(model.InscriptionResourceTaker.AgentEmail, "*****@*****.**", $"Ficha de inscrição (definitiva) recebida. Protocolo efetuado.", model.InscriptionResourceTaker.AgentName, EmailTypes.DefinitiveInscriptionNupInsert, process.InscriptionResourceTaker.CompanyName, process.InscriptionFinancedEnterprise.Title, process.NupProtocol); context.Update(process); } } return((await context.SaveChangesAsync()) > 0); }
public async Task <ActionResult> PostInscriptionProcess( [FromServices] DataContext context, [ModelBinder(BinderType = typeof(JsonWithFilesFormDataModelBinder))] InscriptionProcess model, IFormFile enterpriseSummaryFile, IFormFile budgetWorksheetFile, IFormFile financialScheduleFile, IFormFile technicalDocumentsFile, IFormFile otherDocumentsFile) { if (ModelState.IsValid) { try { model.CreatedOn = DateTime.Now; model.ModifiedOn = DateTime.Now; model.ModifiedBy = ""; AdjustTask(model); context.InscriptionProcesses.Add(model); await context.SaveChangesAsync(); model.EnterpriseSummaryPath = await AddFileAttachment(enterpriseSummaryFile, model.Type, "ResumoEmpreendimento", model.InscriptionProcessId); model.BudgetWorksheetPath = await AddFileAttachment(budgetWorksheetFile, model.Type, "PlanilhaOrcamento", model.InscriptionProcessId); model.FinancialSchedulePath = await AddFileAttachment(financialScheduleFile, model.Type, "CronogramaFinanceiro", model.InscriptionProcessId); model.TechnicalDocumentsPath = await AddFileAttachment(technicalDocumentsFile, model.Type, "DocumentosTecnicos", model.InscriptionProcessId, "Documentos Técnicos.zip"); model.OtherDocumentsPath = await AddFileAttachment(otherDocumentsFile, model.Type, "OutrosDocumentos", model.InscriptionProcessId, "Outros Documentos.zip"); context.InscriptionProcesses.Update(model); if (model.Type == "preinscricao") { EmailSenderInscription.SendEmail(model.InscriptionResourceTaker.AgentEmail, "*****@*****.**", "Ficha de inscrição enviada com sucesso (pré qualificação).", model.InscriptionResourceTaker.AgentName, EmailTypes.PreInscriptionCompletion, model.InscriptionResourceTaker.CompanyName, model.InscriptionFinancedEnterprise.Title); } if (model.Type == "inscricaodefinitiva") { EmailSenderInscription.SendEmail(model.InscriptionResourceTaker.AgentEmail, "*****@*****.**", $"Ficha de inscrição (definitiva) enviada com sucesso.", model.InscriptionResourceTaker.AgentName, EmailTypes.DefinitiveInscriptionCompletion, model.InscriptionResourceTaker.CompanyName, model.InscriptionFinancedEnterprise.Title); } await context.SaveChangesAsync(); return(Ok()); } catch (Exception e) { throw new Exception("Erro: " + e.Message); } } else { return(BadRequest(ModelState)); } }
public async Task <bool> PutPreInscriptionProcessStatus( [FromServices] DataContext context, [FromBody] InscriptionProcess model) { if (ModelState.IsValid) { var process = await context.InscriptionProcesses .Include(x => x.InscriptionFinancedEnterprise) .Include(y => y.InscriptionResourceTaker) .FirstOrDefaultAsync(x => x.InscriptionProcessId == model.InscriptionProcessId); if (model.Status != process.Status) { process.Status = model.Status; process.ModifiedOn = DateTime.Now; process.ModifiedBy = ""; AdjustTask(process); if (process.Status == "Pendente") { EmailSenderInscription.SendEmail(model.InscriptionResourceTaker.AgentEmail, "*****@*****.**", $"O empreendimento possui pendências.", model.InscriptionResourceTaker.AgentName, EmailTypes.PreInscriptionAnalyzis, process.InscriptionResourceTaker.CompanyName, process.InscriptionFinancedEnterprise.Title, process.NupProtocol); } else if (process.Status == "Qualificado") { process.DefinitiveInscriptionProcessGuidLink = Guid.NewGuid().ToString(); EmailSenderInscription.SendEmail(model.InscriptionResourceTaker.AgentEmail, "*****@*****.**", $"O empreendimento foi pré qualificado.", model.InscriptionResourceTaker.AgentName, EmailTypes.PreInscriptionDeferred, process.InscriptionResourceTaker.CompanyName, process.InscriptionFinancedEnterprise.Title, process.NupProtocol, process.DefinitiveInscriptionProcessGuidLink); } else if (process.Status == "Indeferido") { EmailSenderInscription.SendEmail(model.InscriptionResourceTaker.AgentEmail, "*****@*****.**", $"O empreendimento foi indeferido.", model.InscriptionResourceTaker.AgentName, EmailTypes.PreInscriptionRejected, process.InscriptionResourceTaker.CompanyName, process.InscriptionFinancedEnterprise.Title, process.NupProtocol); } context.InscriptionProcessTaskLogs.Add(new InscriptionProcessTaskLog { InscriptionProcessId = process.InscriptionProcessId, ModifiedAt = DateTime.Now, ModifiedBy = model.ModifiedBy, Task = "insercaoStatus", Value = process.Status }); context.Update(process); } } return((await context.SaveChangesAsync()) > 0); }