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")); } }
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")); } }