public async Task <ApiResponse> Handle(AddStoreItemGroupCommand request, CancellationToken cancellationToken)
        {
            ApiResponse response = new ApiResponse();

            try
            {
                if (request != null)
                {
                    StoreItemGroup storeItemGroup = new StoreItemGroup();

                    storeItemGroup.CreatedById   = request.CreatedById;
                    storeItemGroup.CreatedDate   = request.CreatedDate;
                    storeItemGroup.IsDeleted     = false;
                    storeItemGroup.Description   = request.Description;
                    storeItemGroup.InventoryId   = request.InventoryId;
                    storeItemGroup.ItemGroupCode = request.ItemGroupCode;
                    storeItemGroup.ItemGroupName = request.ItemGroupName;

                    await _dbContext.StoreItemGroups.AddAsync(storeItemGroup);

                    await _dbContext.SaveChangesAsync();
                }

                response.StatusCode = StaticResource.successStatusCode;
                response.Message    = "Success";
            }
            catch (Exception ex)
            {
                response.StatusCode = StaticResource.failStatusCode;
                response.Message    = StaticResource.SomethingWrong + ex.Message;
            }

            return(response);
        }
        public async Task <ApiResponse> Handle(GetInventoryItemCodeQuery request, CancellationToken cancellationToken)
        {
            ApiResponse response          = new ApiResponse();
            string      InventoryItemCode = "";

            try
            {
                if (request.Id != 0)
                {
                    StoreInventoryItem storeInventoryItem = await _dbContext.InventoryItems
                                                            .OrderByDescending(x => x.CreatedDate)
                                                            .Include(x => x.StoreItemGroup)
                                                            .FirstOrDefaultAsync(x => x.IsDeleted == false &&
                                                                                 x.ItemGroupId == request.Id);


                    if (storeInventoryItem != null)
                    {
                        int count = Convert.ToInt32(storeInventoryItem.ItemCode.Substring(7));
                        InventoryItemCode = storeInventoryItem.StoreItemGroup.ItemGroupCode + "-" + String.Format("{0:D2}", ++count);
                    }
                    else
                    {
                        StoreItemGroup storeItemGroup = await _dbContext.StoreItemGroups.OrderByDescending(x => x.CreatedDate).FirstOrDefaultAsync(x => x.IsDeleted == false && x.ItemGroupId == request.Id);

                        InventoryItemCode = storeItemGroup.ItemGroupCode + "-" + String.Format("{0:D2}", 1);
                    }
                }

                response.data.InventoryItemCode = InventoryItemCode;
                response.StatusCode             = StaticResource.successStatusCode;
                response.Message = "Success";
            }
            catch (Exception ex)
            {
                response.StatusCode = StaticResource.failStatusCode;
                response.Message    = StaticResource.SomethingWrong + ex.Message;
            }

            return(response);
        }