Ejemplo n.º 1
0
        public HttpResponseMessage Post(UForum f)
        {
            if (f == null)
            {
                return(new HttpResponseMessage(HttpStatusCode.BadRequest));
            }

            forumDB context = new forumDB();

            context.UForums.Add(f);
            context.SaveChanges();
            return(new HttpResponseMessage(HttpStatusCode.Created));
        }
Ejemplo n.º 2
0
        public HttpResponseMessage Delete(int id)
        {
            forumDB context = new forumDB();
            UForum  _f      = context.UForums.Find(id);

            if (_f == null)
            {
                return(new HttpResponseMessage(HttpStatusCode.NotFound));
            }
            context.UForums.Remove(_f);
            try
            {
                context.SaveChanges();
            }
            catch (Exception ex)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.NotFound, ex));
            }
            return(new HttpResponseMessage(HttpStatusCode.OK));
        }
Ejemplo n.º 3
0
        public HttpResponseMessage Put(UForum f)
        {
            forumDB context = new forumDB();
            UForum  _f      = context.UForums.Find(f.ForumId);

            if (_f == null)
            {
                return(new HttpResponseMessage(HttpStatusCode.NotFound));
            }
            _f.ForumName = f.ForumName;

            try
            {
                context.SaveChanges();
            }
            catch (Exception ex)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.NotFound, ex));
            }
            return(new HttpResponseMessage(HttpStatusCode.OK));
        }