Exemple #1
0
        public Task <ResponseModel> SaveChargeDetails(ChargeDetail[] chargeDetails)
        {
            return(Task.Run(async() =>
            {
                ResponseModel responseModel = new ResponseModel();
                List <ChargeDetail> temps = new List <ChargeDetail>();
                foreach (var item in chargeDetails)
                {
                    if (!temps.Exists(p => p.PlateNo.Equals(item.PlateNo) && p.TestNo.Equals(item.TestNo) &&
                                      p.TestItem.Equals(item.TestItem)))
                    {
                        temps.Add(item);
                    }
                }

                if (temps.Count != chargeDetails.Length)
                {
                    responseModel.Code = 0;
                    responseModel.Message = "上传数据中项目重复!";
                }
                else
                {
                    var result = await chargeService.SaveChargeDetails(chargeDetails);
                    responseModel.Code = result.Item1 ? 1 : 0;
                    responseModel.Message = result.Item2;
                }
                return responseModel;
            }));
        }