示例#1
0
 public async Task CreateOrUpdateDimension(DimensionInputDto input)
 {
     if (input.Id != 0)
     {
         await UpdateDimension(input);
     }
     else
     {
         await CreateDimension(input);
     }
 }
示例#2
0
        public async Task CreateDimension(DimensionInputDto input)
        {
            var dimension = input.MapTo <Dimension>();
            var val       = _DimensionRepository
                            .GetAll().Where(p => p.DimensionCode == input.DimensionCode || p.DimensionName == input.DimensionName).FirstOrDefault();

            if (val == null)
            {
                await _DimensionRepository.InsertAsync(dimension);
            }
            else
            {
                throw new UserFriendlyException("Ooops!", "Duplicate Data Occured in Dimension Name '" + input.DimensionName + "' or Dimension Code '" + input.DimensionCode + "'...");
            }
        }
示例#3
0
        public async Task UpdateDimension(DimensionInputDto input)
        {
            var dimension = await _DimensionRepository.GetAsync(input.Id);

            dimension.LastModificationTime = DateTime.Now;
            ObjectMapper.Map(input, dimension);

            var val = _DimensionRepository
                      .GetAll().Where(p => (p.DimensionCode == input.DimensionCode || p.DimensionName == input.DimensionName) && p.Id != input.Id).FirstOrDefault();

            if (val == null)
            {
                await _DimensionRepository.UpdateAsync(dimension);
            }
            else
            {
                throw new UserFriendlyException("Ooops!", "Duplicate Data Occured in Dimension Name '" + input.DimensionName + "' or Dimension Code '" + input.DimensionCode + "'...");
            }
        }