/// <summary> /// Get the RollupCenterDetails by Id /// </summary> /// <param name="input"></param> /// <returns></returns> public async Task <RollupCenterUnitDto> GetRollupCenterUnitById(IdInput input) { RollupCenterUnit rollupCenteritem = await _rollupCenterUnitRepository.GetAsync(input.Id); RollupCenterUnitDto result = rollupCenteritem.MapTo <RollupCenterUnitDto>(); result.RollupCenterId = rollupCenteritem.Id; return(result); }
/// <summary> /// Validating the RollupCenterUnit /// </summary> /// <param name="rollupCenterUnit"></param> /// <returns></returns> protected virtual async Task ValidateRollupCenterUnitAsync(RollupCenterUnit rollupCenterUnit) { //Validating if Duplicate Caption exists if (RollupCenterRepository != null) { var rollupCenter = (await RollupCenterRepository.GetAllListAsync(p => p.Caption == rollupCenterUnit.Caption && p.OrganizationUnitId == rollupCenterUnit.OrganizationUnitId)); if (rollupCenterUnit.Id == 0) { if (rollupCenter.Count > 0) { throw new UserFriendlyException(L("Duplicate Caption", rollupCenterUnit.Caption)); } } else { if (rollupCenter.FirstOrDefault(p => p.Id != rollupCenterUnit.Id && p.Caption == rollupCenterUnit.Caption) != null) { throw new UserFriendlyException(L("Duplicate Caption", rollupCenterUnit.Caption)); } } } }
/// <summary> /// Updating RollupCenterUnit Details /// </summary> /// <param name="rollupCenterUnit"></param> /// <returns></returns> public virtual async Task UpdateAsync(RollupCenterUnit rollupCenterUnit) { await ValidateRollupCenterUnitAsync(rollupCenterUnit); await RollupCenterRepository.UpdateAsync(rollupCenterUnit); }