コード例 #1
0
        public async Task <HttpResponseMessage> PutMantenimientoPredictivo(MantenimientoPredictivo MantenimientoPredictivo)
        {
            try
            {
                _mantenimientoPredictivo = await db.MantenimientoPredictivo.FindAsync(MantenimientoPredictivo.IdMantenimientoPredictivo);

                if (_mantenimientoPredictivo == null)
                {
                    return(new HttpResponseMessage(HttpStatusCode.NoContent));
                }
                else
                {
                    _mantenimientoPredictivo.Fecha    = MantenimientoPredictivo.Fecha;
                    _mantenimientoPredictivo.IdArea   = MantenimientoPredictivo.IdArea;
                    _mantenimientoPredictivo.IdUnidad = MantenimientoPredictivo.IdUnidad;

                    await db.SaveChangesAsync();

                    return(new HttpResponseMessage(HttpStatusCode.OK));
                }
            }
            catch (Exception ex)
            {
                return(new HttpResponseMessage(HttpStatusCode.InternalServerError)
                {
                    Content = new StringContent(ex.Message)
                });
            }
        }
コード例 #2
0
        public async Task <HttpResponseMessage> GetMantenimientoPredictivo(IdModelMantenimientoPredictivo Id)
        {
            try
            {
                _mantenimientoPredictivo = await db.MantenimientoPredictivo.FindAsync(Id.IdMantenimientoPredictivo);

                if (_mantenimientoPredictivo == null)
                {
                    return(new HttpResponseMessage(HttpStatusCode.NoContent));
                }
                else
                {
                    return(new HttpResponseMessage(HttpStatusCode.OK)
                    {
                        Content = new StringContent(JsonConvert.SerializeObject(_mantenimientoPredictivo), System.Text.Encoding.UTF8, "application/json")
                    });
                }
            }
            catch (Exception ex)
            {
                return(new HttpResponseMessage(HttpStatusCode.InternalServerError)
                {
                    Content = new StringContent(ex.Message)
                });
            }
        }
コード例 #3
0
        public async Task <HttpResponseMessage> DeleteMantenimientoPredictivo(IdModelMantenimientoPredictivo Id)
        {
            try
            {
                _mantenimientoPredictivo = await db.MantenimientoPredictivo.FindAsync(Id.IdMantenimientoPredictivo);

                if (_mantenimientoPredictivo == null)
                {
                    return(new HttpResponseMessage(HttpStatusCode.NoContent));
                }
                else
                {
                    db.Entry(_mantenimientoPredictivo).State = EntityState.Modified;
                    await db.SaveChangesAsync();

                    return(new HttpResponseMessage(HttpStatusCode.OK));
                }
            }
            catch (Exception ex)
            {
                return(new HttpResponseMessage(HttpStatusCode.InternalServerError)
                {
                    Content = new StringContent(ex.Message)
                });
            }
        }
コード例 #4
0
 protected override void Dispose(bool disposing)
 {
     if (disposing)
     {
         _mantenimientosPredictivo = null;
         _mantenimientoPredictivo  = null;
         db.Dispose();
     }
     base.Dispose(disposing);
 }
コード例 #5
0
        public async Task <HttpResponseMessage> PostMantenimientoPredictivo(MantenimientoPredictivo MantenimientoPredictivo)
        {
            try
            {
                db.MantenimientoPredictivo.Add(MantenimientoPredictivo);
                await db.SaveChangesAsync();

                return(new HttpResponseMessage(HttpStatusCode.OK));
            }
            catch (Exception ex)
            {
                return(new HttpResponseMessage(HttpStatusCode.InternalServerError)
                {
                    Content = new StringContent(ex.Message)
                });
            }
        }