Example #1
0
 public HttpResponseMessage Put(int id, VideosFLCLS videosFLCLS)
 {
     try
     {
         id = videosFLCLS.vid_id;
         using (steujedo_sindicatoEntities db = new steujedo_sindicatoEntities())
         {
             Videos_FL video = db.Videos_FL.Where(p => p.vid_id.Equals(id)).First();
             if (video == null)
             {
                 return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "Video no encontrado"));
             }
             else
             {
                 video.vid_titulo = videosFLCLS.vid_titulo;
                 video.vid_src    = videosFLCLS.vid_src;
                 video.vid_ancho  = videosFLCLS.vid_ancho;
                 video.vid_largo  = videosFLCLS.vid_largo;
                 db.SaveChanges();
                 return(Request.CreateResponse(HttpStatusCode.OK));
             }
         }
     }
     catch (Exception ex)
     {
         return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex.StackTrace));
     }
 }
Example #2
0
        public HttpResponseMessage Post(string usuario, VideosFLCLS videosFLCLS)
        {
            try
            {
                using (steujedo_sindicatoEntities db = new steujedo_sindicatoEntities())
                {
                    Videos_FL video = new Videos_FL();
                    video.vid_titulo    = videosFLCLS.vid_titulo;
                    video.vid_src       = videosFLCLS.vid_src;
                    video.vid_ancho     = videosFLCLS.vid_ancho;
                    video.vid_largo     = videosFLCLS.vid_largo;
                    video.vid_u_publica = usuario;
                    video.vid_f_publica = DateTime.Now;


                    db.Videos_FL.Add(video);
                    db.SaveChanges();
                    var Mensaje = Request.CreateResponse(HttpStatusCode.Created, video);

                    return(Mensaje);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.InnerException);
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex.InnerException));
            }
        }