public HttpResponseMessage Detail(IdModelGuiaServicioModel Id)
        {
            GuiaServicio guia = new GuiaServicio();

            try
            {
                if (Id != null)
                {
                    guia = db.GuiaServicio.Where(x => x.IdGuiaServicio == Id.IdGuiaServicio).FirstOrDefault();
                }
                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 + "Guia de Servicio"));
            }
        }
        public HttpResponseMessage EditHeader(GuiaServicioModel guiam)
        {
            GuiaServicio guiaServicio = new GuiaServicio();

            try
            {
                if (guiam != null)
                {
                    guiaServicio = db.GuiaServicio.Where(x => x.IdGuiaServicio == guiam.IdGuiaServicio).FirstOrDefault();

                    guiaServicio.IdArea      = guiam.IdArea;
                    guiaServicio.IdMarca     = guiam.IdMarca;
                    guiaServicio.IdModelo    = guiam.IdModelo;
                    guiaServicio.Km_Hr       = guiam.Km_Hr;
                    guiaServicio.Descripcion = guiam.Descripcion;
                    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 + "Guia de Servicio"));
            }
        }
        public HttpResponseMessage DeleteHeader(IdModelGuiaServicioModel id)
        {
            GuiaServicio guia = new GuiaServicio();

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

                    guia.Activo_Inactivo = false;
                    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 + "Guia de Servicio"));
            }
        }
        public HttpResponseMessage CreateHeader(GuiaServicioModel guiam)
        {
            GuiaServicio guiaServicio = new GuiaServicio();

            try
            {
                int idguia = 0;
                if (guiam != null)
                {
                    guiaServicio.IdArea = guiam.IdArea;

                    guiaServicio.IdMarca         = guiam.IdMarca;
                    guiaServicio.IdModelo        = guiam.IdModelo;
                    guiaServicio.Km_Hr           = guiam.Km_Hr;
                    guiaServicio.Descripcion     = guiam.Descripcion;
                    guiaServicio.Activo_Inactivo = true;
                    db.GuiaServicio.Add(guiaServicio);
                    db.SaveChanges();
                    var guia = db.GuiaServicio.Where(x => x.IdArea == guiaServicio.IdArea && x.IdMarca == guiaServicio.IdMarca && x.IdModelo == guiaServicio.IdModelo && x.Descripcion.Equals(guiaServicio.Descripcion, StringComparison.InvariantCultureIgnoreCase)).FirstOrDefault();
                    idguia = guia.IdGuiaServicio;
                    return(new HttpResponseMessage(System.Net.HttpStatusCode.OK)
                    {
                        Content = new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(idguia), 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 + "Guia de Servicio"));
            }
        }