public ActionResult <RequestSubCategoryDTO> PostRequestSubCategoryDTO(RequestSubCategoryDTO requestSubCategoryDTO)
        {
            _requestSubCategoryRepository.Add(requestSubCategoryDTO);
            _requestSubCategoryRepository.Save();

            return(CreatedAtAction("GetRequestSubCategoryDTO", new { id = requestSubCategoryDTO.Id }, requestSubCategoryDTO));
        }
        public void Update(RequestSubCategoryDTO requestSubCategoryDTO)
        {
            var requestSubCategory = new RequestSubCategory();

            requestSubCategory.Id = requestSubCategoryDTO.Id;
            requestSubCategory.RequestCategoryId     = requestSubCategoryDTO.RequestCategoryId;
            requestSubCategory.SubCategoryName       = requestSubCategoryDTO.SubCategoryName;
            _context.Entry(requestSubCategory).State = EntityState.Modified;
        }
        public void Add(RequestSubCategoryDTO requestSubCategoryDTO)
        {
            var requestSubCategory = new RequestSubCategory();

            //requestSubCategory.Id = requestSubCategoryDTO.Id;
            requestSubCategory.RequestCategoryId = requestSubCategoryDTO.RequestCategoryId;
            requestSubCategory.SubCategoryName   = requestSubCategoryDTO.SubCategoryName;
            _context.requestSubCategories.Add(requestSubCategory);
        }
        public RequestSubCategoryDTO GetById(int id)
        {
            var sub = _context.requestSubCategories.Include(sub => sub.RequestCategory).Where(s => s.Id == id).FirstOrDefault();
            var requestSubCategory = new RequestSubCategoryDTO
            {
                Id = sub.Id,
                SubCategoryName     = sub.SubCategoryName,
                RequestCategoryId   = sub.RequestCategoryId,
                RequestCategoryName = sub.RequestCategory.CategoryName
            };

            return(requestSubCategory);
        }
        public IActionResult PutRequestSubCategoryDTO(int id, RequestSubCategoryDTO requestSubCategoryDTO)
        {
            if (id != requestSubCategoryDTO.Id)
            {
                return(BadRequest());
            }

            _requestSubCategoryRepository.Update(requestSubCategoryDTO);

            try
            {
                _requestSubCategoryRepository.Save();
            }
            catch (DbUpdateConcurrencyException ex)
            {
                string msg = ex.Message;
            }

            return(NoContent());
        }