Beispiel #1
0
        public async Task <HttpResponseMessage> DetailAsync(IdModelBacklog Id)
        {
            BackLog guia = new BackLog();

            try
            {
                if (Id != null)
                {
                    guia = await db.BackLog.FindAsync(Id.IdBackLog).ConfigureAwait(false);
                }
                if (guia != null)
                {
                    return new HttpResponseMessage(HttpStatusCode.OK)
                           {
                               Content = new StringContent(JsonConvert.SerializeObject(guia), System.Text.Encoding.UTF8, "application/json")
                           }
                }
                ;
                else
                {
                    return new HttpResponseMessage(System.Net.HttpStatusCode.NoContent)
                           {
                               Content = null
                           }
                };
            }
            catch (Exception ex)
            {
                return(Request.CreateResponse <string>(HttpStatusCode.InternalServerError, ex.Message + Environment.NewLine + "BackLog"));
            }
        }
Beispiel #2
0
        public HttpResponseMessage ExecutedHeader(IdModelBacklog id)
        {
            BackLog guia = new BackLog();

            try
            {
                if (id != null)
                {
                    guia = db.BackLog.Where(x => x.IdBackLog == id.IdBackLog).FirstOrDefault();

                    guia.Ejecutada = true;
                    db.SaveChanges();
                    return(new HttpResponseMessage(System.Net.HttpStatusCode.OK)
                    {
                        Content = null
                    });
                }
                else
                {
                    return new HttpResponseMessage(System.Net.HttpStatusCode.NoContent)
                           {
                               Content = null
                           }
                };
            }
            catch (Exception ex)
            {
                return(Request.CreateResponse <string>(HttpStatusCode.InternalServerError, ex.Message + Environment.NewLine + "BackLog"));
            }
        }
Beispiel #3
0
        public HttpResponseMessage DeleteHeader(IdModelBacklog id)
        {
            BackLog guia = new BackLog();
            List <BackLogMaterial>  backLogMaterial  = new List <BackLogMaterial>();
            List <BackLogPuesto>    backLogPuesto    = new List <BackLogPuesto>();
            List <BackLogRefaccion> backLogRefaccion = new List <BackLogRefaccion>();

            try
            {
                if (id != null)
                {
                    backLogMaterial = db.BackLogMaterial.Where(x => x.IdBackLog == id.IdBackLog).ToList();

                    if (backLogMaterial != null)
                    {
                        foreach (BackLogMaterial logMaterial in backLogMaterial)
                        {
                            db.BackLogMaterial.Remove(logMaterial);
                        }
                    }
                    backLogPuesto = db.BackLogPuesto.Where(x => x.IdBackLog == id.IdBackLog).ToList();
                    if (backLogPuesto != null)
                    {
                        foreach (BackLogPuesto logMaterial in backLogPuesto)
                        {
                            db.BackLogPuesto.Remove(logMaterial);
                        }
                    }
                    backLogRefaccion = db.BackLogRefaccion.Where(x => x.IdBackLog == id.IdBackLog).ToList();
                    if (backLogRefaccion != null)
                    {
                        foreach (BackLogRefaccion logMaterial in backLogRefaccion)
                        {
                            db.BackLogRefaccion.Remove(logMaterial);
                        }
                    }
                    guia = db.BackLog.Where(x => x.IdBackLog == id.IdBackLog).FirstOrDefault();
                    db.BackLog.Remove(guia);
                    db.SaveChanges();
                    return(new HttpResponseMessage(System.Net.HttpStatusCode.OK)
                    {
                        Content = null
                    });
                }
                else
                {
                    return new HttpResponseMessage(System.Net.HttpStatusCode.NoContent)
                           {
                               Content = null
                           }
                };
            }
            catch (Exception ex)
            {
                return(Request.CreateResponse <string>(HttpStatusCode.InternalServerError, ex.Message + Environment.NewLine + "BackLog"));
            }
        }