public IActionResult AddPart([FromBody] PartAddForm part)
        {
            var id       = _furnitureService.AddPart(part);
            var response = _furnitureService.GetSingle <Part, PartResponse>(id);

            return(StatusCode(201, response));
        }
        public int AddPart(PartAddForm part)
        {
            var toAdd     = Mapper.Map(part).ToANew <Part>();
            var duplicate = _context.Parts.Any(x => x.Name == part.Name && x.PieceOfFurnitureId == part.PieceOfFurnitureId);

            if (duplicate)
            {
                throw new HttpStatusCodeException(HttpStatusCode.InternalServerError, _localizer["Already exists"]);
            }

            toAdd.Color            = _context.Colors.Find(part.ColorId) ?? throw new HttpStatusCodeException(HttpStatusCode.NotFound, _localizer["Could not find a color"]);
            toAdd.Pattern          = _context.Patterns.Find(part.PatternId) ?? throw new HttpStatusCodeException(HttpStatusCode.NotFound, _localizer["Could not find a pattern"]);
            toAdd.Material         = _context.Materials.Find(part.MaterialId) ?? throw new HttpStatusCodeException(HttpStatusCode.NotFound, _localizer["Could not find a material"]);
            toAdd.PieceOfFurniture = _context.Furniture.Find(part.PieceOfFurnitureId) ?? throw new HttpStatusCodeException(HttpStatusCode.NotFound, _localizer["Could not find furniture part"]);;
            _context.Parts.Add(toAdd);
            if (_context.SaveChanges() == 0)
            {
                throw new HttpStatusCodeException(HttpStatusCode.InternalServerError, _localizer["Could not add data"]);
            }

            return(toAdd.PartId);
        }