Beispiel #1
0
        public async Task SaveYearAsync(SysDictionaryEditDto input)
        {
            var item   = input.MapTo <SysDictionary>();
            var dbItem =
                this._sysDictionaryRepository.FirstOrDefault(
                    r => r.Category == input.Category && r.Value == input.Value); //存在预算年度

            if (dbItem == null)
            {
                var defaultYear =
                    this._sysDictionaryRepository.FirstOrDefault(
                        r => r.Category == input.Category && r.Value4 == true.ToString()); //item4:是否是当前年度
                if (defaultYear != null)
                {
                    defaultYear.Value4 = false.ToString();
                }

                item.Value4 = true.ToString();
                await this._sysDictionaryRepository.InsertAsync(item);
            }
            else
            {
                throw new UserFriendlyException("该预算年度已存在");
            }
        }
Beispiel #2
0
 public async Task SaveAsync(SysDictionaryEditDto input)
 {
     if (input.Category.Contains("Year"))
     {
         input.Value2 = new DateTime(input.Value.ToInt(), 1, 1).ToString();
         input.Value3 = new DateTime(input.Value.ToInt(), 12, 31).ToString();
         await this.SaveYearAsync(input);
     }
     else
     {
         var item = input.MapTo <SysDictionary>();
         if (input.Id == Guid.Empty)
         {
             await this._sysDictionaryRepository.InsertAsync(item);
         }
         else
         {
             var old = this._sysDictionaryRepository.Get(input.Id);
             Mapper.Map(input, old);
             await this._sysDictionaryRepository.UpdateAsync(old);
         }
     }
 }