Ejemplo n.º 1
0
        public async Task <HttpResponseMessage> GetOrdenTrabajo(IdModelOrdenTrabajo Id)
        {
            try
            {
                _ordenTrabajo = await db.OrdenTrabajo.FindAsync(Id.IdOrdenTrabajo);

                if (_ordenTrabajo == null)
                {
                    return(new HttpResponseMessage(HttpStatusCode.NoContent));
                }
                else
                {
                    return(new HttpResponseMessage(HttpStatusCode.OK)
                    {
                        Content = new StringContent(JsonConvert.SerializeObject(_ordenTrabajo), System.Text.Encoding.UTF8, "application/json")
                    });
                }
            }
            catch (Exception ex)
            {
                return(new HttpResponseMessage(HttpStatusCode.InternalServerError)
                {
                    Content = new StringContent(ex.Message)
                });
            }
        }
Ejemplo n.º 2
0
        public async Task <HttpResponseMessage> DeleteOrdenTrabajo(IdModelOrdenTrabajo Id)
        {
            try
            {
                _ordenTrabajo = await db.OrdenTrabajo.FindAsync(Id.IdOrdenTrabajo);

                if (_ordenTrabajo == null)
                {
                    return(new HttpResponseMessage(HttpStatusCode.NoContent));
                }
                else
                {
                    _ordenTrabajo.Activo_Inactivo = false;
                    db.Entry(_ordenTrabajo).State = EntityState.Modified;
                    await db.SaveChangesAsync();

                    return(new HttpResponseMessage(HttpStatusCode.OK));
                }
            }
            catch (Exception ex)
            {
                return(new HttpResponseMessage(HttpStatusCode.InternalServerError)
                {
                    Content = new StringContent(ex.Message)
                });
            }
        }
Ejemplo n.º 3
0
        public async Task <HttpResponseMessage> GetDetailsWorkOrder(IdModelOrdenTrabajo ordenTrabajo)
        {
            try
            {
                db.Configuration.LazyLoadingEnabled = false;
                var _lordenTrabajo = await db.DetalleOrdenTrabajo.Where(x => x.IdOrdenTrabajo == ordenTrabajo.IdOrdenTrabajo).ToListAsync().ConfigureAwait(false);

                return(new HttpResponseMessage(HttpStatusCode.OK)
                {
                    Content = new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(_lordenTrabajo), System.Text.Encoding.UTF8, "application/json")
                });
            }
            catch (Exception ex)
            {
                return(new HttpResponseMessage(HttpStatusCode.InternalServerError)
                {
                    Content = new StringContent(ex.Message)
                });
            }
        }
Ejemplo n.º 4
0
        public async Task <HttpResponseMessage> GetServiceGuides(IdModelOrdenTrabajo ordenTrabajo)
        {
            try
            {
                var _lordenTrabajo = await db.OrdenTrabajo.Include(o => o.Unidad).ToListAsync().ConfigureAwait(false);

                var _ordenTrabajo  = _lordenTrabajo.Where(x => x.IdOrdenTrabajo == ordenTrabajo.IdOrdenTrabajo).First();
                var _guiasServicio = await db.GuiaServicio.Where(x => x.IdMarca == _ordenTrabajo.Unidad.IdMarca && x.IdModelo == _ordenTrabajo.Unidad.IdModelo && x.IdArea == _ordenTrabajo.IdArea).ToListAsync().ConfigureAwait(false);

                return(new HttpResponseMessage(HttpStatusCode.OK)
                {
                    Content = new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(_guiasServicio), System.Text.Encoding.UTF8, "application/json")
                });
            }
            catch (Exception ex)
            {
                return(new HttpResponseMessage(HttpStatusCode.InternalServerError)
                {
                    Content = new StringContent(ex.Message)
                });
            }
        }
Ejemplo n.º 5
0
        public async Task <HttpResponseMessage> GetBacklog(IdModelOrdenTrabajo ordenTrabajo)
        {
            try
            {
                var _lordenTrabajo = await db.OrdenTrabajo.Include(o => o.Unidad).ToListAsync().ConfigureAwait(false);

                var _ordenTrabajo = _lordenTrabajo.Where(x => x.IdOrdenTrabajo == ordenTrabajo.IdOrdenTrabajo).First();
                db.Configuration.LazyLoadingEnabled = false;
                //var _Backlogs = await db.BackLog.Where(x => x.IdUnidad == _ordenTrabajo.Unidad.IdUnidad && x.IdArea == _ordenTrabajo.IdArea && x.Ejecutada == false).ToListAsync().ConfigureAwait(false);
                var _Backlogs = await db.BackLog.Where(x => x.IdUnidad == _ordenTrabajo.Unidad.IdUnidad && x.Ejecutada == false).ToListAsync().ConfigureAwait(false);

                return(new HttpResponseMessage(HttpStatusCode.OK)
                {
                    Content = new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(_Backlogs), System.Text.Encoding.UTF8, "application/json")
                });
            }
            catch (Exception ex)
            {
                return(new HttpResponseMessage(HttpStatusCode.InternalServerError)
                {
                    Content = new StringContent(ex.Message)
                });
            }
        }