public async Task <ActionResult <StoreProductCategoryResult> > CreateAssignments(List <StoreProductCategory> assignments)
        {
            StoreProductCategoryResult result = new StoreProductCategoryResult();

            foreach (var assignment in assignments)
            {
                assignment.CreatedAt = DateTime.Now;
                try
                {
                    var created = await _storeProductCatRepository.CreateAsync(assignment);

                    result.IsSuccessful = true;
                    result.ResultData.Add(created);
                }
                catch (ItemAlreadyExistsException e)
                {
                    result.IsSuccessful = false;
                    result.ResultData   = null;
                    result.ErrorMessages.Add(e.Message);
                    return(Conflict(result));
                }
                catch (Exception e)
                {
                    throw e;
                }
            }
            return(Ok(result));
        }
        public async Task <ActionResult <StoreProductCategoryResult> > UpdateOfStore(string id, [FromBody] List <StoreProductCategory> assignments)
        {
            StoreProductCategoryResult result = new StoreProductCategoryResult();

            if (assignments.Any(a => a.StoreId != id))
            {
                result.IsSuccessful = false;
                result.ErrorMessages.Add("Id does not match value in object");
                return(BadRequest(result));
            }
            try
            {
                var update = await _storeProductCatRepository.UpdateOfStore(id, assignments);

                result.IsSuccessful = true;
                result.ResultData   = update;
            }
            catch (ItemNotFoundException e)
            {
                result.IsSuccessful = false;
                result.ErrorMessages.Add(e.Message);
                return(NotFound(result));
            }
            catch (ItemAlreadyExistsException e)
            {
                result.IsSuccessful = false;
                result.ErrorMessages.Add(e.Message);
                return(NotFound(result));
            }
            catch (Exception e)
            {
                throw e;
            }
            return(Ok(result));
        }
        public async Task <ActionResult <StoreProductCategoryResult> > GetAssignmentsByStoreId(string id)
        {
            var assignments = await _storeProductCatRepository.GetAssignmentsByStoreIdAsync(id);

            var result = new StoreProductCategoryResult();

            result.IsSuccessful = true;
            result.ResultData   = assignments;
            return(Ok(result));
        }
        public async Task <ActionResult <StoreProductCategoryResult> > DeleteAllOfStore(string id)
        {
            StoreProductCategoryResult result = new StoreProductCategoryResult();

            try
            {
                result.IsSuccessful = await _storeProductCatRepository.DeleteAllOfStore(id);
            }
            catch (ItemNotFoundException e)
            {
                result.IsSuccessful = false;
                result.ErrorMessages.Add(e.Message);
                return(NotFound(result));
            }
            catch (Exception e)
            {
                throw e;
            }
            return(Ok(result));
        }