コード例 #1
0
        public HttpResponseMessage EditDetail(DetalleGuiaServicioModel guiam)
        {
            DetalleGuiaServicio detalleGuia = new DetalleGuiaServicio();

            try
            {
                if (guiam != null)
                {
                    detalleGuia = db.DetalleGuiaServicio.Where(x => x.IdDetalleGuiaServicio == guiam.IdDetalleGuiaServicio).FirstOrDefault();

                    detalleGuia.IdGuiaServicio = guiam.IdGuiaServicio;
                    detalleGuia.Actividad      = guiam.Actividad;
                    detalleGuia.Tiempo         = guiam.Tiempo;
                    detalleGuia.Observaciones  = guiam.Observaciones;
                    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"));
            }
        }
コード例 #2
0
        public HttpResponseMessage DeleteDetail(IdModelGuiaServicioModelDetails id)
        {
            DetalleGuiaServicio guia = new DetalleGuiaServicio();

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

                    if (guia != null)
                    {
                        db.DetalleGuiaServicio.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 + "Guia de Servicio"));
            }
        }
コード例 #3
0
        public HttpResponseMessage CreateDetail(DetalleGuiaServicioModel guiam)
        {
            DetalleGuiaServicio detalleGuia = new DetalleGuiaServicio();

            try
            {
                int idguia = 0;
                if (guiam != null)
                {
                    detalleGuia.IdGuiaServicio = guiam.IdGuiaServicio;

                    detalleGuia.Actividad     = guiam.Actividad;
                    detalleGuia.Tiempo        = guiam.Tiempo;
                    detalleGuia.Observaciones = guiam.Observaciones;
                    db.DetalleGuiaServicio.Add(detalleGuia);
                    db.SaveChanges();
                    var guia = db.DetalleGuiaServicio.Where(x => x.IdGuiaServicio == detalleGuia.IdGuiaServicio && x.Actividad.Equals(detalleGuia.Actividad, StringComparison.InvariantCultureIgnoreCase)).FirstOrDefault();
                    idguia = guia.IdDetalleGuiaServicio;
                    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"));
            }
        }