public static BitacoraBarrenacion voToObject(BitacoraBarrenacionVo vo) { return(new BitacoraBarrenacion { id = vo.id, maquinaria = new Maquinaria { id = vo.maquinaria_id }, operador = new Operador { id = vo.operador_id }, ayudante = new Operador { id = vo.ayudante_id }, turno = vo.turno, fecha_bitacora = Convert.ToDateTime(vo.fecha_bitacora), mesa = vo.mesa, beta = vo.beta, vale_acero = vo.vale_acero, comentarios = vo.comentarios, metros_finales = vo.metros_finales, hora_primer_barreno = Convert.ToDateTime(vo.hora_primer_barreno), hora_ultimo_barreno = Convert.ToDateTime(vo.hora_ultimo_barreno), status_edicion = vo.status_edicion, dias_apertura_calendario = vo.dias_apertura_calendario, user = new Models.Auth.User { id = vo.user_id } }); }
public HttpResponseMessage update([FromBody] BitacoraBarrenacionVo bitacora_vo) { TransactionResult tr = bitacora_service.update(bitacora_vo, new Models.Auth.User { id = int.Parse(RequestContext.Principal.Identity.Name) }); IDictionary <string, string> data = new Dictionary <string, string>(); if (tr == TransactionResult.OK) { data.Add("message", "Object updated."); return(Request.CreateResponse(HttpStatusCode.OK, data)); } else { data.Add("message", "There was an error attending your request."); return(Request.CreateResponse(HttpStatusCode.BadRequest, data)); } }
public HttpResponseMessage autorizarRango([FromBody] BitacoraBarrenacionVo bitacora_vo) { TransactionResult tr = bitacora_service.autorizarRango(bitacora_vo); IDictionary <string, string> data = new Dictionary <string, string>(); if (tr == TransactionResult.OK) { data.Add("message", "Rango actualizado."); return(Request.CreateResponse(HttpStatusCode.Created, data)); } else if (tr == TransactionResult.EXISTS) { data.Add("message", "Object already existed."); return(Request.CreateResponse(HttpStatusCode.Conflict, data)); } else { data.Add("message", "There was an error attending your request."); return(Request.CreateResponse(HttpStatusCode.BadRequest, data)); } }
public TransactionResult create(BitacoraBarrenacionVo bitacora_vo, User user_log) { if (bitacora_vo.comentarios == null) { bitacora_vo.comentarios = ""; } if (bitacora_vo.mesa == null) { bitacora_vo.mesa = ""; } if (bitacora_vo.beta == null) { bitacora_vo.beta = ""; } if (bitacora_vo.vale_acero == null) { bitacora_vo.vale_acero = ""; } BitacoraBarrenacion obj = BitacoraBarrenacionAdapter.voToObject(bitacora_vo); obj.user = user_log; int id = bitacora_repository.create(obj); if (id > 0) { var tr = TransactionResult.CREATED; if (bitacora_vo.demoras != null) { //Agregar demoras foreach (DetalleDemoraBitacoraVo dvo in bitacora_vo.demoras) { dvo.bitacora_barrenacion_id = id; dvo.tipo_bitacora = 2; tr = bitacora_repository.createDetalleDemoraBitacora(DetalleDemoraBitacoraAdapter.voToObject(dvo)); if (tr != TransactionResult.CREATED) { return(tr); } } } if (bitacora_vo.lineas != null) { //Agregar lineas foreach (LineaVo lin in bitacora_vo.lineas) { lin.bitacora_id = id; int idL = bitacora_repository.createLineaBitacora(LineaAdapter.voToObject(lin)); if (idL > 0) { if (lin.barrenos != null) { foreach (BarrenoVo bvo in lin.barrenos) { bvo.bitacora_id = bitacora_vo.id; bvo.linea_id = idL; tr = bitacora_repository.createBarrenoLineaBitacora(BarrenoAdapter.voToObject(bvo)); if (tr != TransactionResult.CREATED) { return(tr); } } } } } } return(tr); } return(TransactionResult.ERROR); //return bitacora_repository.create(obj); }
public TransactionResult autorizarRango(BitacoraBarrenacionVo bitacora_vo) { return(bitacora_repository.autorizarRango(BitacoraBarrenacionAdapter.voToObject(bitacora_vo))); }
public TransactionResult update(BitacoraBarrenacionVo bitacora_vo, User user_log) { if (bitacora_vo.comentarios == null) { bitacora_vo.comentarios = ""; } bitacora_vo.user_id = user_log.id; //Eliminamos los detalles existentes bitacora_repository.deleteDetalleDemoraBitacora(bitacora_vo.id); bitacora_repository.deleteBarrenosByIdBitacora(bitacora_vo.id); bitacora_repository.deleteLineaByIdBitacora(bitacora_vo.id); //Creamos las demoras y lineas if (bitacora_vo.demoras != null || bitacora_vo.lineas != null) { var tr = TransactionResult.CREATED; if (bitacora_vo.demoras != null) { //Agregar demoras foreach (DetalleDemoraBitacoraVo dvo in bitacora_vo.demoras) { dvo.bitacora_barrenacion_id = bitacora_vo.id; dvo.tipo_bitacora = 2; tr = bitacora_repository.createDetalleDemoraBitacora(DetalleDemoraBitacoraAdapter.voToObject(dvo)); if (tr != TransactionResult.CREATED) { return(tr); } } } if (bitacora_vo.lineas != null) { //Agregar lineas foreach (LineaVo lin in bitacora_vo.lineas) { lin.bitacora_id = bitacora_vo.id; int idL = bitacora_repository.createLineaBitacora(LineaAdapter.voToObject(lin)); if (idL > 0) { if (lin.barrenos != null) { foreach (BarrenoVo bvo in lin.barrenos) { bvo.bitacora_id = bitacora_vo.id; bvo.linea_id = idL; tr = bitacora_repository.createBarrenoLineaBitacora(BarrenoAdapter.voToObject(bvo)); if (tr != TransactionResult.CREATED) { return(tr); } } } } } } } return(bitacora_repository.update(BitacoraBarrenacionAdapter.voToObject(bitacora_vo))); }