Exemplo n.º 1
0
        public List <SubCategoryAdmin> DeleteSubCategory(int id)
        {
            List <SubCategoryAdmin> subcategories = new List <SubCategoryAdmin>();


            try
            {
                subcategories = _subcategory_object.DeleteSubCategory(id);
                if (subcategories != null)
                {
                    return(subcategories);
                }
                else
                {
                    throw new OASCustomException("Operation failed.");
                }
            }
            catch (SqlException sqlex)
            {
                log.Error(sqlex);
            }
            catch (OASCustomException customex)
            {
                log.Error(customex.Message);
            }
            catch (Exception ex)
            {
                log.Error(ex.Message);
            }
            return(subcategories);
        }
        public async Task <HttpResponseMessage> DeleteSubCategory(int id)
        {
            try
            {
                int response = await subCatOp.DeleteSubCategory(id);

                if (response == 0)
                {
                    return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "SubCategory with Id = " + id.ToString() + " not found to delete"));
                }
                else
                {
                    return(Request.CreateResponse(HttpStatusCode.OK, "SubCategory with Id = " + id.ToString() + " is deleted"));
                }
            }
            catch (Exception ex)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex.Message));
            }
        }