Example #1
0
        // Category Converter
        public static CategoryDTO ToDto(this Community_Showcase_Category item)
        {
            CategoryDTO dto = new CategoryDTO()
            {
                id   = item.id,
                name = item.name
            };

            return(dto);
        }
        public HttpResponseMessage Put(CategoryDTO dto)
        {
            try
            {
                Community_Showcase_Category category = dc.Community_Showcase_Categories.Where(i => i.id == dto.id).SingleOrDefault();
                category = dto.ToItem(category);

                dc.SubmitChanges();
                return(Request.CreateResponse(HttpStatusCode.OK, dto));
            }
            catch (Exception ex)
            {
                Exceptions.LogException(ex);
                return(Request.CreateResponse(HttpStatusCode.InternalServerError, ex));
            }
        }
Example #3
0
        public static Community_Showcase_Category ToItem(this CategoryDTO dto, Community_Showcase_Category item)
        {
            if (item == null)
            {
                item = new Community_Showcase_Category();
            }

            if (dto == null)
            {
                return(item);
            }

            item.id   = dto.id;
            item.name = dto.name;

            return(item);
        }
        public HttpResponseMessage Post(CategoryDTO dto)
        {
            try
            {
                Community_Showcase_Category category = dto.ToItem(null);

                int user_id = DotNetNuke.Entities.Users.UserController.Instance.GetCurrentUserInfo().UserID;

                dc.Community_Showcase_Categories.InsertOnSubmit(category);

                dc.SubmitChanges();
                return(Request.CreateResponse(HttpStatusCode.OK, dto));
            }
            catch (Exception ex)
            {
                Exceptions.LogException(ex);
                return(Request.CreateResponse(HttpStatusCode.InternalServerError, ex));
            }
        }
        public HttpResponseMessage Get(int id)
        {
            try
            {
                Community_Showcase_Category item = dc.Community_Showcase_Categories.Where(i => i.id == id).SingleOrDefault();

                if (item == null)
                {
                    return(Request.CreateResponse(HttpStatusCode.NotFound));
                }

                return(Request.CreateResponse(HttpStatusCode.OK, item.ToDto()));;
            }
            catch (Exception ex)
            {
                Exceptions.LogException(ex);
                return(Request.CreateResponse(HttpStatusCode.InternalServerError, ex));
            }
        }
        public HttpResponseMessage Delete(int id)
        {
            try
            {
                Community_Showcase_Category item = dc.Community_Showcase_Categories.Where(i => i.id == id).SingleOrDefault();

                if (item == null)
                {
                    return(Request.CreateResponse(HttpStatusCode.NotFound));
                }

                dc.Community_Showcase_Categories.DeleteOnSubmit(item);
                dc.SubmitChanges();

                return(Request.CreateResponse(HttpStatusCode.OK));
            }
            catch (Exception ex)
            {
                Exceptions.LogException(ex);
                return(Request.CreateResponse(HttpStatusCode.InternalServerError, ex));
            }
        }
 partial void DeleteCommunity_Showcase_Category(Community_Showcase_Category instance);
 partial void InsertCommunity_Showcase_Category(Community_Showcase_Category instance);