Beispiel #1
0
        public async Task <IActionResult> Create([FromBody] CreateSubCategoryRequest SubCategoryRequst)
        {
            var SubCategory = new SubCategory
            {
                CategoryId  = SubCategoryRequst.CategoryId,
                ArabicName  = SubCategoryRequst.ArabicName,
                EnglishName = SubCategoryRequst.EnglishName,
                ImgUrl      = SubCategoryRequst.ImgUrl,
                Status      = SubCategoryRequst.Status
            };

            var status = await _SubCategoryService.CreateSubCategoryAsync(SubCategory);

            if (status == -1)
            {
                return(Conflict(new ErrorResponse
                {
                    message = "Dublicate Entry",
                    status = Conflict().StatusCode
                }));
            }

            if (status == 1)
            {
                var response = new SubCategoryResponse {
                    Id = SubCategory.Id
                };
                return(Ok(response));
            }
            return(NotFound(new ErrorResponse
            {
                message = "Not Found",
                status = NotFound().StatusCode
            }));
        }