Exemple #1
0
        /// <summary>
        /// Validating TerritoriesUnit
        /// </summary>
        /// <param name="territoriesunit"></param>
        /// <returns></returns>
        protected virtual async Task ValidateTerritorieUnitAsync(TerritoriesUnit territoriesunit)
        {
            //Validating if Duplicate Territories exists
            if (TerritoriesUnitRepository != null)
            {
                var territorie = (await TerritoriesUnitRepository.GetAllListAsync(p => p.Description == territoriesunit.Description));

                if (territoriesunit.Id == 0)
                {
                    if (territorie.Count > 0)
                    {
                        throw new UserFriendlyException(L("DuplicateTerritorie", territoriesunit.Description));
                    }
                }
                else
                {
                    if (territorie.FirstOrDefault(p => p.Id != territoriesunit.Id && p.Description == territoriesunit.Description) != null)
                    {
                        throw new UserFriendlyException(L("DuplicateTerritorie", territoriesunit.Description));
                    }
                }
            }
        }
Exemple #2
0
        /// <summary>
        ///  Updating TerritoriesUnit Details
        /// </summary>
        /// <param name="territoriesunit"></param>
        /// <returns></returns>
        public virtual async Task UpdateAsync(TerritoriesUnit territoriesunit)
        {
            await ValidateTerritorieUnitAsync(territoriesunit);

            await TerritoriesUnitRepository.UpdateAsync(territoriesunit);
        }