Beispiel #1
0
        public HttpResponseMessage EditHeader(BackLogModel guiam)
        {
            BackLog backLog = new BackLog();

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

                    backLog.IdUnidad  = guiam.IdUnidad;
                    backLog.Fecha     = guiam.Fecha;
                    backLog.Actividad = guiam.Actividad;
                    backLog.Tiempo    = guiam.Tiempo;
                    backLog.Ejecutada = guiam.Ejecutada;
                    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 #2
0
        public HttpResponseMessage CreateHeader(BackLogModel guiam)
        {
            BackLog backLog = new BackLog();

            try
            {
                int idback = 0;
                if (guiam != null)
                {
                    backLog.IdUnidad = guiam.IdUnidad;

                    backLog.Fecha     = guiam.Fecha;
                    backLog.Actividad = guiam.Actividad;
                    backLog.Tiempo    = guiam.Tiempo;
                    backLog.Ejecutada = false;
                    db.BackLog.Add(backLog);
                    db.SaveChanges();

                    DateTime fecha = Convert.ToDateTime(guiam.Fecha.ToShortDateString());
                    var      guia  = db.BackLog.Where(x => x.IdUnidad == x.IdUnidad && x.Actividad == guiam.Actividad && x.Fecha == fecha && x.Tiempo == guiam.Tiempo).FirstOrDefault();
                    idback = guia.IdBackLog;
                    return(new HttpResponseMessage(System.Net.HttpStatusCode.OK)
                    {
                        Content = new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(idback), 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"));
            }
        }