Esempio n. 1
0
        /// <summary>
        /// Validating the VendorData
        /// </summary>
        /// <param name="vendorUnit"></param>
        /// <returns></returns>
        protected virtual async Task ValidateVendorUnitAsync(VendorUnit vendorUnit)
        {
            //Validating if Duplicate VendorName exists
            if (VendorUnitRepository != null)
            {
                var vendorsUnit = (await VendorUnitRepository.GetAllListAsync(p => p.LastName == vendorUnit.LastName && p.OrganizationUnitId == vendorUnit.OrganizationUnitId));

                if (vendorUnit.Id == 0)
                {
                    if (vendorsUnit.Count > 0)
                    {
                        throw new UserFriendlyException(L("Duplicate Name", vendorUnit.LastName));
                    }
                }
                else
                {
                    if (vendorsUnit.FirstOrDefault(p => p.Id != vendorUnit.Id && p.LastName == vendorUnit.LastName) != null)
                    {
                        throw new UserFriendlyException(L("Duplicate Name", vendorUnit.LastName));
                    }
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Updating Vendor Details
        /// </summary>
        /// <param name="vendor"></param>
        /// <returns></returns>
        public virtual async Task UpdateAsync(VendorUnit vendor)
        {
            await ValidateVendorUnitAsync(vendor);

            await VendorUnitRepository.UpdateAsync(vendor);
        }