public static async Task <Response <OrdenMasivaResponse> > AnularCorrectivo(OrdenMasivaRequest request) { Response <OrdenMasivaResponse> response; List <OrdenMasivaList> ListInsertar; decimal numInforme; ListInsertar = request.ListInsertar; try { foreach (var item in ListInsertar) { if (!item.Correctivo) { continue; } numInforme = Convert.ToDecimal(item.NumeroOrden); await SolicitudRevisionTecnicaData.AnularSolicitudRevisionTecnica_C_Correctivo(numInforme); await InformeData.AnularInforme(numInforme, "1"); await ProgramacionData.UpdateProgramacionOrdenCorrectivoAnulacion(item.Codi_Programacion); if (item.Preventivo) { //await SolicitudRevisionTecnicaData.AnularSolicitudRevisionTecnica_C_Correctivo(numInforme); await InformeData.AnularInforme(numInforme, "0"); await ProgramacionData.UpdateProgramacionOrdenPreventivoAnulacion(item.Codi_Programacion); } } response = new Response <OrdenMasivaResponse> { EsCorrecto = true, Valor = new OrdenMasivaResponse { List = new List <OrdenMasivaList>() }, Mensaje = "OK", Estado = true, }; return(response); } catch (FaultException <ServiceError> ) { throw; } catch (Exception ex) { return(new Response <OrdenMasivaResponse>(false, null, Functions.MessageError(ex), false)); } }
public static async Task <Response <InformeResponse> > AnularInforme(int IdInforme) { Response <InformeResponse> response; InformeEntity objInforme; ProgramacionEntity objProgramacionCorrectivo; ProgramacionEntity objProgramacionPreventivo; string codProgramacion; try { objInforme = InformeData.SelectInforme(IdInforme); objProgramacionCorrectivo = ProgramacionData.SelectProgramacionPorInforme(objInforme.NumeroInforme.ToString(), Convert.ToInt32(Constants.TipoInforme.CORRECTIVO)); objProgramacionPreventivo = ProgramacionData.SelectProgramacionPorInforme(objInforme.NumeroInforme.ToString(), Convert.ToInt32(Constants.TipoInforme.PREVENTIVO)); codProgramacion = objProgramacionCorrectivo.CODI_PROGRAMACION; if (objInforme.TipoInforme == Constants.TipoInforme.CORRECTIVO && objProgramacionPreventivo != null) { BusinessException.Generar(Constants.PRIMERO_DEBE_ANULAR_PREVENTIVO); } //using (TransactionScope tran = new TransactionScope()) //{ if (objInforme.TipoInforme == Constants.TipoInforme.CORRECTIVO) { await ProgramacionData.UpdateProgramacionOrdenCorrectivoAnulacion(codProgramacion); } else if (objInforme.TipoInforme == Constants.TipoInforme.PREVENTIVO) { await ProgramacionData.UpdateProgramacionOrdenPreventivoAnulacion(codProgramacion); } await InformeData.AnularInforme(IdInforme); // tran.Complete(); //} response = new Response <InformeResponse> { EsCorrecto = true, Valor = new InformeResponse { Informe = new InformeEntity() }, Mensaje = "OK", Estado = true, }; return(response); } catch (Exception ex) { return(new Response <InformeResponse>(false, null, Functions.MessageError(ex), false)); } }