Exemplo n.º 1
0
        /// <summary>
        /// Validating Sub Account
        /// </summary>
        /// <param name="subAccountUnit"></param>
        /// <returns></returns>
        protected virtual async Task ValidateSubAccountUnitAsync(SubAccountUnit subAccountUnit)
        {
            //Validating if Duplicate Sub Account exists
            if (SubAccountUnitRepository != null)
            {
                var subaccountunit = (await SubAccountUnitRepository.GetAllListAsync(p => p.SubAccountNumber == subAccountUnit.SubAccountNumber && p.OrganizationUnitId == subAccountUnit.OrganizationUnitId && p.TenantId == subAccountUnit.TenantId));

                if (subAccountUnit.Id == 0)
                {
                    if (subaccountunit.Count > 0)
                    {
                        throw new UserFriendlyException(L("Duplicate Sub Account", subAccountUnit.Caption));
                    }
                }
                else
                {
                    if (subaccountunit.FirstOrDefault(p => p.Id != subAccountUnit.Id && p.SubAccountNumber == subAccountUnit.SubAccountNumber) != null)
                    {
                        throw new UserFriendlyException(L("Duplicate Sub Account", subAccountUnit.Caption));
                    }
                }
            }
        }
Exemplo n.º 2
0
        public virtual async Task UpdateAsync(SubAccountUnit subAccountUnit)
        {
            await ValidateSubAccountUnitAsync(subAccountUnit);

            await SubAccountUnitRepository.UpdateAsync(subAccountUnit);
        }
Exemplo n.º 3
0
        public virtual async Task <long> CreateAsync(SubAccountUnit subAccountUnit)
        {
            await ValidateSubAccountUnitAsync(subAccountUnit);

            return(await SubAccountUnitRepository.InsertAndGetIdAsync(subAccountUnit));
        }