コード例 #1
0
        public async Task <ResultDto> AddReportMealInfo(List <ReportMeal> model)
        {
            var result = await _context.GetByWhere(where => where.IsDeleted == 0 && where.ReportMealUserID.Equals(model[0].ReportMealUserId));

            foreach (var meal in model)
            {
                if (result.Where(where => where.ReportMealTime.Equals(meal.ReportMealTime)).ToList().Count > 0)
                {
                    // 这一天已经报餐,请重新选择一天进行报餐。
                    throw new Exception(string.Format("【{0}】Meals have been reported on this day, please select a new day to report meals.", meal.ReportMealTime));
                }
            }
            var addModel = model.Select(
                m => new HW_ReportMealInfo()
            {
                ReportMealUserID = m.ReportMealUserId,
                ReportMealTime   = m.ReportMealTime,
                Lunch            = m.Lunch,
                Dinner           = m.Dinner
            }).ToList();

            return(new ResultDto()
            {
                Success = await _context.AddRange(addModel)
            });
        }
コード例 #2
0
        public async Task AddRange(IEnumerable <tblOwner> entities)
        {
            if ((await _ownerRepository.FindAsync(o => entities.Select(e => e.Id).Contains(o.Id)).ConfigureAwait(false)).Any())
            {
                throw new ArgumentException("One of the owners already exist.");
            }

            _ownerRepository.AddRange(entities);
        }
コード例 #3
0
        public async Task <ResultDto> AddPhoneReceiveInfo(List <AddPhoneReceiveInfoDto> modelList)
        {
            // 判断是否有未归还的手机
            var result = await GetPhoneReceiveInfoByUserId(modelList[0].ReceiveUserID);

            if (result.PhoneModelList.Count > 0)
            {
                // 当前用户领取手机未归还,请先归还再做处理。
                throw new Exception("The current user picks up the mobile phone and has not returned it. Please return it before processing.");
            }
            return(new ResultDto
            {
                Success =
                    await _context.AddRange(ModelBindingService.CopyModelList <HW_PhoneReceiveInfo, AddPhoneReceiveInfoDto>(modelList))
            });
        }