public async Task <Model.Services.Common.Result> FlowRegister([FromBody] Model.Services.Business.FlowRequest model) { try { Model.Services.Common.Result result = new Model.Services.Common.Result(); result.Data = await _businessService.RegisterFlow(model); result.Success = true; result.ResultMessage = "Fluxo cadastrado com sucesso"; return(result); } catch (Exception ex) { return(new Model.Services.Common.Result() { Success = false, ResultMessage = $"Ocorreu um erro durante a operação. Descricao: {ex.Message}" }); } }
public Task <Model.Services.Business.Flow> RegisterFlow(Model.Services.Business.FlowRequest model) { Model.Services.Business.Flow flow = new Model.Services.Business.Flow() { CNPJ = model.CNPJ, Description = model.Description, FlowType = model.FlowType.ToString(), Value = model.Value }; Model.Database.Negocios.Empresa empresa = _businessRepository.GetEmpresa( new Model.Database.Negocios.Empresa() { CNPJ = model.CNPJ }); Model.Database.Negocios.TypFlx typFlx = _businessRepository.GetFlowType( new Model.Database.Negocios.TypFlx() { TypeFlow = model.FlowType.ToString() }); Model.Database.Negocios.Finac finac = _businessRepository.RegisterFlow( new Model.Database.Negocios.Finac() { MonthReference = model.MonthReference, IdCompany = empresa.id, IdFlowType = typFlx.Id, Description = model.Description, Value = model.Value, DataRegister = System.DateTime.Now, ParcelAmount = model.ParcelAmount }); flow.IdFlow = finac.Id; return(Task.FromResult(flow)); }