public async Task <List <RequestResponseModel.SmartSortResponse> > GetAllSmartSort(bool isActive = true)
        {
            List <RequestResponseModel.SmartSortResponse> listSmartSort = new List <RequestResponseModel.SmartSortResponse>();

            var listSmartSortAll = await _smartSortRepository.GetAllSmartSortAsync(isActive);

            if (listSmartSortAll == null)
            {
                return(null);
            }

            foreach (var smartSort in listSmartSortAll)
            {
                listSmartSort.Add(new RequestResponseModel.SmartSortResponse()
                {
                    Id = smartSort.SmartSortColumnKey.ToString(), Name = smartSort.ColumnNameText, IsActive = smartSort.ActiveFlag
                });
            }
            return(listSmartSort);
        }
Example #2
0
        public async Task <BusinessResponse> PutSmartSortForTransactionPriorityAsync(string transactionPriorityKey, string facilityKey, List <TransactionPrioritySmartSortPut> listTransactionPrioritySmartSortPut, Dictionary <string, string> headers)
        {
            var isTransactionPriorityExist = _transactionPriorityRepository.GetByTransactionPriorityAndFacilityKey(Guid.Parse(transactionPriorityKey), Guid.Parse(facilityKey));

            if (isTransactionPriorityExist == null)
            {
                return(new BusinessResponse()
                {
                    IsSuccesss = false, Message = "No transaction priority exist."
                });
            }

            var smartSorts = await _smartSortRepository.GetAllSmartSortAsync(true);

            if (smartSorts == null || smartSorts.ToList().Count == 0 || listTransactionPrioritySmartSortPut.Count > smartSorts.ToList().Count)
            {
                return(new BusinessResponse()
                {
                    IsSuccesss = false, Message = "No Such SmartSort exist."
                });
            }

            foreach (var transactionPrioritySmartSortPut in listTransactionPrioritySmartSortPut)
            {
                bool smartSortExist = true;
                foreach (var smartSort in smartSorts)
                {
                    if (smartSort.SmartSortColumnKey.ToString().ToLower() == transactionPrioritySmartSortPut.SmartSortColumnKey.ToLower())
                    {
                        smartSortExist = true;
                        break;
                    }
                    else
                    {
                        smartSortExist = false;
                    }
                }
                if (!smartSortExist)
                {
                    return(new BusinessResponse()
                    {
                        IsSuccesss = false, Message = "No SmartSort is present "
                    });
                }
            }

            List <SmartSort> listSmartSort = new List <SmartSort>();

            foreach (var transactionPrioritySmartSort in listTransactionPrioritySmartSortPut)
            {
                if (transactionPrioritySmartSort.SmartSortOrder > smartSorts.ToList().Count || transactionPrioritySmartSort.SmartSortOrder < 1)
                {
                    return(new BusinessResponse()
                    {
                        IsSuccesss = false, Message = "Smart Sort order is not correct."
                    });
                }
                listSmartSort.Add(new SmartSort()
                {
                    SmartSortColumnKey = new Guid(transactionPrioritySmartSort.SmartSortColumnKey), TransPriorityKey = new Guid(transactionPriorityKey), SmartSortOrder = transactionPrioritySmartSort.SmartSortOrder, TenantKey = Guid.Parse(_executionContextAccessor.Current.Tenant.TenantKey), LastModifiedUTCDateTime = DateTime.UtcNow, LastModifiedByActorKey = Utility.GetNewGuid(), CreatedByActorKey = Utility.GetNewGuid(), CreatedDateTime = DateTimeOffset.Now
                });
            }

            await _transactionPrioritySmartSortRepository.PutSmartSortForTransactionPriorityAsync(new Guid(transactionPriorityKey), listSmartSort);

            _unitOfWork.CommitChanges();
            SendEventSmartSort(listSmartSort, "Update", headers);
            return(new BusinessResponse()
            {
                IsSuccesss = true, Message = "Smart Sorts Updated."
            });
        }