public IActionResult PutSupplier(int id, [FromBody] SupplierWithoutProductsDto supplier, int accountId = -1)
        {
            if (supplier is null)
            {
                return(BadRequest());
            }
            if (!_arepo.AuthorizeUser(accountId, Permission.AddSupplier))
            {
                return(Unauthorized());
            }
            var(isValid, errs) = supplier.Validate();
            if (!isValid)
            {
                return(BadRequest(errs));
            }

            if (!_repo.SupplierExists(id))
            {
                return(NotFound());
            }
            supplier.SupplierId = id;
            var supToUpdate = Mapper.Map <Supplier>(supplier);

            return(_repo.UpdateSupplier(supToUpdate) ?
                   new StatusCodeResult(StatusCodes.Status204NoContent) :
                   new StatusCodeResult(StatusCodes.Status500InternalServerError));
        }
        public IActionResult PostSupplier([FromBody] SupplierWithoutProductsDto supplier, int accountId = -1)
        {
            if (supplier is null)
            {
                return(BadRequest());
            }
            if (!_arepo.AuthorizeUser(accountId, Permission.AddSupplier))
            {
                return(Unauthorized());
            }
            var(isValid, errors) = supplier.Validate();
            if (!isValid)
            {
                return(BadRequest(errors));
            }

            var supToAdd = Mapper.Map <Supplier>(supplier);

            return(_repo.AddSupplier(supToAdd) ?
                   new StatusCodeResult(StatusCodes.Status201Created) :
                   new StatusCodeResult(StatusCodes.Status500InternalServerError));
        }