Esempio n. 1
0
        /// <summary>
        /// Get the SalesRep Details By Id
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public async Task <SalesRepUnitDto> GetSalesRepUnitsById(IdInput input)
        {
            SalesRepUnit salesRepItem = await _salesRepUnitRepository.GetAsync(input.Id);

            SalesRepUnitDto result = salesRepItem.MapTo <SalesRepUnitDto>();

            result.SalesRepId = salesRepItem.Id;
            return(result);
        }
Esempio n. 2
0
        /// <summary>
        /// Validating SalesRepUnit
        /// </summary>
        /// <param name="salesRepUnit"></param>
        /// <returns></returns>
        protected virtual async Task ValidateSalesRepUnitAsync(SalesRepUnit salesRepUnit)
        {
            //Validating if Duplicate SalesRep exists
            if (SalesRepUnitRepository != null)
            {
                var salesRep = (await SalesRepUnitRepository.GetAllListAsync(p => p.LastName == salesRepUnit.LastName && p.OrganizationUnitId == salesRepUnit.OrganizationUnitId));

                if (salesRepUnit.Id == 0)
                {
                    if (salesRep.Count > 0)
                    {
                        throw new UserFriendlyException(L("Duplicate Name", salesRepUnit.LastName));
                    }
                }
                else
                {
                    if (salesRep.FirstOrDefault(p => p.Id != salesRepUnit.Id && p.LastName == salesRepUnit.LastName) != null)
                    {
                        throw new UserFriendlyException(L("Duplicate Name", salesRepUnit.LastName));
                    }
                }
            }
        }
Esempio n. 3
0
        /// <summary>
        ///  Updating SalesRepUnit Details
        /// </summary>
        /// <param name="salesrepunit"></param>
        /// <returns></returns>
        public virtual async Task UpdateAsync(SalesRepUnit salesrepunit)
        {
            await ValidateSalesRepUnitAsync(salesrepunit);

            await SalesRepUnitRepository.UpdateAsync(salesrepunit);
        }