Exemplo n.º 1
0
        /// <summary>
        ///     Disables the specified identifier.
        /// </summary>
        /// <param name="id">The identifier.</param>
        /// <returns>Task&lt;Outlet&gt;.</returns>
        public async Task<Outlet> Disable(int id)
        {
            using (ChePingContext db = new ChePingContext())
            {
                Outlet outlet = await db.Outlets.FirstOrDefaultAsync(o => o.Id == id);
                if (outlet != null && outlet.Available)
                {
                    outlet.Available = false;
                    await db.ExecuteSaveChangesAsync();
                }

                return outlet;
            }
        }
Exemplo n.º 2
0
        /// <summary>
        ///     Disables the specified identifier.
        /// </summary>
        /// <param name="id">The identifier.</param>
        /// <returns>Task&lt;User&gt;.</returns>
        public async Task<User> Disable(int id)
        {
            using (ChePingContext db = new ChePingContext())
            {
                User user = await db.Users.FirstOrDefaultAsync(u => u.Id == id);
                if (user != null && user.Available)
                {
                    user.Available = false;
                    await db.ExecuteSaveChangesAsync();
                }

                return user;
            }
        }
Exemplo n.º 3
0
        /// <summary>
        ///     Disables the specified identifier.
        /// </summary>
        /// <param name="id">The identifier.</param>
        /// <returns>Task&lt;Model&gt;.</returns>
        public async Task<Model> Disable(int id)
        {
            using (ChePingContext db = new ChePingContext())
            {
                Model model = await db.Models.FirstOrDefaultAsync(m => m.Id == id);
                if (model != null && model.Available)
                {
                    model.Available = false;
                    await db.ExecuteSaveChangesAsync();
                }

                return model;
            }
        }
Exemplo n.º 4
0
        /// <summary>
        ///     accept price as an asynchronous operation.
        /// </summary>
        /// <param name="caseId">The case identifier.</param>
        /// <returns>Task&lt;Case&gt;.</returns>
        /// <exception cref="System.ApplicationException">未能加载事项信息</exception>
        public async Task<Case> AcceptPriceAsync(int caseId)
        {
            using (ChePingContext db = new ChePingContext())
            {
                Case @case = await db.Cases.FirstOrDefaultAsync(c => c.Id == caseId);
                if (@case == null)
                {
                    throw new ApplicationException("未能加载事项信息");
                }

                if (@case.State == State.Qiatan)
                {
                    @case.State = State.ShenqingDakuan;
                    this.RecordTime(@case, State.Qiatan);

                    await db.ExecuteSaveChangesAsync();
                }

                return @case;
            }
        }
Exemplo n.º 5
0
        /// <summary>
        ///     Rejects the specified case identifier.
        /// </summary>
        /// <param name="caseId">The case identifier.</param>
        /// <param name="message">The message.</param>
        /// <returns>Task&lt;Case&gt;.</returns>
        /// <exception cref="System.ApplicationException">未能加载事项信息</exception>
        public async Task<Case> RejectAsync(int caseId, string message)
        {
            using (ChePingContext db = new ChePingContext())
            {
                Case @case = await db.Cases.FirstOrDefaultAsync(c => c.Id == caseId);
                if (@case == null)
                {
                    throw new ApplicationException("未能加载事项信息");
                }

                this.RecordTime(@case, @case.State);

                switch (@case.State)
                {
                    case State.Shenhe:
                        @case.State = State.ShenheShibai;
                        break;

                    case State.Yanche:
                        @case.State = State.YancheShibai;
                        break;

                    case State.Baojia:
                        @case.State = State.FangqiBaojia;
                        break;

                    case State.Qiatan:
                        @case.State = State.QiatanShibai;
                        break;

                    case State.ShenqingDakuan:
                        @case.State = State.FangqiShenqingDakuan;
                        break;

                    case State.DakuanShenhe:
                        @case.State = State.DakuanShenheShibai;
                        break;

                    case State.Caigou:
                        @case.State = State.CaigouShibai;
                        break;
                }

                @case.AbandonReason = message;
                @case.Abandon = false;
                await db.ExecuteSaveChangesAsync();

                return @case;
            }
        }
Exemplo n.º 6
0
        /// <summary>
        ///     Approves the payment.
        /// </summary>
        /// <param name="caseId">The case identifier.</param>
        /// <returns>Task&lt;Case&gt;.</returns>
        public async Task<Case> ApprovePaymentAsync(int caseId)
        {
            using (ChePingContext db = new ChePingContext())
            {
                Case @case = await db.Cases.FirstOrDefaultAsync(c => c.Id == caseId);
                if (@case == null)
                {
                    throw new ApplicationException("未能加载事项信息");
                }

                if (@case.State == State.DakuanShenhe)
                {
                    @case.State = State.Caigou;
                    this.RecordTime(@case, State.DakuanShenhe);
                    await db.ExecuteSaveChangesAsync();
                }

                await this.smsService.SendNoticeMessage(@case.PurchaserId);

                return @case;
            }
        }
Exemplo n.º 7
0
        /// <summary>
        ///     Apply the payment.
        /// </summary>
        /// <param name="caseId">The case identifier.</param>
        /// <param name="price">The price.</param>
        /// <returns>Task&lt;Case&gt;.</returns>
        /// <exception cref="ApplicationException">
        ///     未能加载事项信息
        ///     or
        ///     无法加载用户信息
        ///     or
        ///     无在岗总经理
        /// </exception>
        public async Task<Case> ApplyPaymentAsync(int caseId, int price)
        {
            using (ChePingContext db = new ChePingContext())
            {
                Case @case = await db.Cases.FirstOrDefaultAsync(c => c.Id == caseId);
                if (@case == null)
                {
                    throw new ApplicationException("未能加载事项信息");
                }

                if (@case.State == State.ShenqingDakuan)
                {
                    this.RecordTime(@case, State.ShenqingDakuan);

                    //alloc managerId
                    User user = await db.Users.FirstOrDefaultAsync(u => u.Id == @case.PurchaserId && u.JobTitle == JobTitle.Purchaser && u.Available);
                    if (user == null)
                    {
                        throw new ApplicationException("无法加载用户信息");
                    }

                    List<User> managers = await db.Users.Where(u => u.Available && u.JobTitle == JobTitle.Manager).ToListAsync();

                    if (managers.Count == 0)
                    {
                        throw new ApplicationException("无在岗总经理");
                    }

                    int caseCount = await db.Cases.CountAsync(c => ManagerTodoStates.Contains(c.State) && c.ManagerId != null);
                    int index = caseCount % managers.Count;
                    int managerId = managers[index].Id;

                    @case.State = State.DakuanShenhe;
                    @case.PurchasePrice = price;
                    @case.ManagerId = managerId;

                    await db.ExecuteSaveChangesAsync();

                    await this.smsService.SendNoticeMessage(@case.ManagerId.GetValueOrDefault());
                }

                return @case;
            }
        }
Exemplo n.º 8
0
        /// <summary>
        ///     Adds the yanche information.
        /// </summary>
        /// <param name="caseId">The case identifier.</param>
        /// <param name="yancheInfo">The yanche information.</param>
        /// <param name="photos">The photos.</param>
        /// <returns>Task&lt;Case&gt;.</returns>
        /// <exception cref="ApplicationException">
        ///     事项的状态不合法
        ///     or
        ///     未能加载验车信息
        ///     or
        ///     无法加载用户信息
        ///     or
        ///     无在岗查询师
        ///     or
        ///     查询师分配错误
        /// </exception>
        /// <exception cref="System.ApplicationException">
        ///     事项的状态不合法
        ///     or
        ///     未能加载验车信息
        /// </exception>
        public async Task<Case> AddYancheInfoAsync(int caseId, VehicleInspection yancheInfo, IEnumerable<int> photos)
        {
            using (ChePingContext db = new ChePingContext())
            {
                Case @case = await db.Cases.FirstOrDefaultAsync(c => c.Id == caseId);

                if (@case == null || @case.State != State.Yanche)
                {
                    throw new ApplicationException("事项的状态不合法");
                }

                VehicleInspection inspection = await db.VehicleInspections.FirstOrDefaultAsync(i => i.Id == @case.VehicleInspecId);
                if (inspection == null)
                {
                    throw new ApplicationException("未能加载验车信息");
                }

                inspection.VinCode = yancheInfo.VinCode;
                inspection.EngineCode = yancheInfo.EngineCode;
                inspection.InsuranceCode = yancheInfo.InsuranceCode;
                inspection.LicenseCode = yancheInfo.LicenseCode;

                @case.State = State.Chaxun;
                this.RecordTime(@case, State.Yanche);

                User user = await db.Users.FirstOrDefaultAsync(u => u.Id == @case.PurchaserId && u.JobTitle == JobTitle.Purchaser && u.Available);
                if (user == null)
                {
                    throw new ApplicationException("无法加载用户信息");
                }

                int queryingId;

                List<User> queryings = await db.Users.Where(u => u.Available && u.JobTitle == JobTitle.Querying).ToListAsync();

                var workingQueryings = await db.Cases.Where(c => QueryingTodoStates.Contains(c.State) && c.QueryingId != null)
                    .GroupBy(c => c.QueryingId).Select(g => new { g.Key, Count = g.Count() }).ToListAsync();

                queryings.RemoveAll(v => workingQueryings.Select(i => i.Key).Contains(v.Id));

                if (queryings.Count > 0)
                {
                    queryingId = queryings[0].Id;
                }
                else
                {
                    if (workingQueryings.Count == 0)
                    {
                        throw new ApplicationException("无在岗查询师");
                    }

                    queryingId = workingQueryings.OrderBy(v => v.Count).Select(v => v.Key).First().GetValueOrDefault();

                    if (queryingId == 0)
                    {
                        throw new ApplicationException("查询师分配错误");
                    }
                }

                @case.QueryingId = queryingId;

                foreach (int photo in photos)
                {
                    Photo photoModel = await db.Photos.FirstOrDefaultAsync(p => p.Id == photo);

                    if (photoModel != null)
                    {
                        photoModel.CaseId = caseId;
                    }
                }

                await db.ExecuteSaveChangesAsync();

                await this.smsService.SendNoticeMessage(@case.QueryingId.GetValueOrDefault());

                return @case;
            }
        }
Exemplo n.º 9
0
        /// <summary>
        ///     add value information as an asynchronous operation.
        /// </summary>
        /// <param name="caseId">The case identifier.</param>
        /// <param name="valueInfo">The value information.</param>
        /// <param name="price">The price.</param>
        /// <returns>Task&lt;Case&gt;.</returns>
        /// <exception cref="ApplicationException">
        ///     事项的状态不合法
        ///     or
        ///     未能加载验车信息
        /// </exception>
        /// <exception cref="System.ApplicationException">
        ///     事项的状态不合法
        ///     or
        ///     未能加载验车信息
        /// </exception>
        public async Task<Case> AddValueInfoAsync(int caseId, VehicleInspection valueInfo, int price)
        {
            using (ChePingContext db = new ChePingContext())
            {
                Case @case = await db.Cases.FirstOrDefaultAsync(c => c.Id == caseId);

                if (@case == null || @case.State != State.Pinggu)
                {
                    throw new ApplicationException("事项的状态不合法");
                }

                VehicleInspection inspection = await db.VehicleInspections.FirstOrDefaultAsync(i => i.Id == @case.VehicleInspecId);
                if (inspection == null)
                {
                    throw new ApplicationException("未能加载验车信息");
                }

                inspection.PreferentialPrice = valueInfo.PreferentialPrice;
                inspection.MaxMileage = valueInfo.MaxMileage;
                inspection.MinMileage = valueInfo.MinMileage;
                inspection.SaleGrade = valueInfo.SaleGrade;
                inspection.WebAveragePrice = valueInfo.WebAveragePrice;
                inspection.WebPrice = valueInfo.WebPrice;
                inspection.FloorPrice = valueInfo.FloorPrice;

                this.RecordTime(@case, State.Pinggu);

                //alloc directorId
                User user = await db.Users.FirstOrDefaultAsync(u => u.Id == @case.PurchaserId && u.JobTitle == JobTitle.Purchaser && u.Available);
                if (user == null)
                {
                    throw new ApplicationException("无法加载用户信息");
                }

                List<User> directors = await db.Users.Where(u => u.Available && u.OutletId == user.OutletId && u.JobTitle == JobTitle.Director).ToListAsync();

                if (directors.Count == 0)
                {
                    throw new ApplicationException("无在岗地区总监");
                }

                int caseCount = await db.Cases.CountAsync(c => c.OutletId == user.OutletId && DirectorTodoStates.Contains(c.State) && c.DirectorId != null);
                int index = caseCount % directors.Count;

                int directorId = directors[index].Id;

                @case.State = State.Shenhe;
                @case.PurchasePrice = price;
                @case.DirectorId = directorId;

                await db.ExecuteSaveChangesAsync();

                return @case;
            }
        }
Exemplo n.º 10
0
        /// <summary>
        ///     add qiatan information as an asynchronous operation.
        /// </summary>
        /// <param name="caseId">The case identifier.</param>
        /// <param name="qiatanInfo">The qiatan information.</param>
        /// <returns>Task&lt;Case&gt;.</returns>
        /// <exception cref="ApplicationException">
        ///     事项的状态不合法
        ///     or
        ///     未能加载验车信息
        /// </exception>
        public async Task<Case> AddQiatanInfoAsync(int caseId, VehicleInspection qiatanInfo)
        {
            using (ChePingContext db = new ChePingContext())
            {
                Case @case = await db.Cases.FirstOrDefaultAsync(c => c.Id == caseId);

                if (@case == null || @case.State != State.Qiatan)
                {
                    throw new ApplicationException("事项的状态不合法");
                }

                VehicleInspection inspection = await db.VehicleInspections.FirstOrDefaultAsync(i => i.Id == @case.VehicleInspecId);
                if (inspection == null)
                {
                    throw new ApplicationException("未能加载验车信息");
                }

                inspection.VehicleOwner = qiatanInfo.VehicleOwner;
                inspection.VehicleOwnerCellphone = qiatanInfo.VehicleOwnerCellphone;
                inspection.VehicleOwnerBank = qiatanInfo.VehicleOwnerBank;
                inspection.VehicleOwnerBankCardNo = qiatanInfo.VehicleOwnerBankCardNo;
                inspection.VehicleOwnerIdNo = qiatanInfo.VehicleOwnerIdNo;

                @case.State = State.ShenqingDakuan;
                this.RecordTime(@case, State.Qiatan);

                await db.ExecuteSaveChangesAsync();

                await this.smsService.SendNoticeMessage(@case.DirectorId.GetValueOrDefault());

                return @case;
            }
        }
Exemplo n.º 11
0
        /// <summary>
        ///     add chaxun information as an asynchronous operation.
        /// </summary>
        /// <param name="caseId">The case identifier.</param>
        /// <param name="chaxunInfo">The chaxun information.</param>
        /// <returns>Task&lt;Case&gt;.</returns>
        /// <exception cref="System.ApplicationException">
        ///     事项的状态不合法
        ///     or
        ///     未能加载验车信息
        /// </exception>
        public async Task<Case> AddChaxunInfoAsync(int caseId, VehicleInspection chaxunInfo)
        {
            using (ChePingContext db = new ChePingContext())
            {
                Case @case = await db.Cases.FirstOrDefaultAsync(c => c.Id == caseId);

                if (@case == null || @case.State != State.Chaxun)
                {
                    throw new ApplicationException("事项的状态不合法");
                }

                VehicleInspection inspection = await db.VehicleInspections.FirstOrDefaultAsync(i => i.Id == @case.VehicleInspecId);
                if (inspection == null)
                {
                    throw new ApplicationException("未能加载验车信息");
                }

                inspection.RealMileage = chaxunInfo.RealMileage;
                inspection.LastConservationTime = chaxunInfo.LastConservationTime;
                inspection.ConservationState = chaxunInfo.ConservationState;
                inspection.ConservationNote = chaxunInfo.ConservationNote;
                inspection.ClaimState = chaxunInfo.ClaimState;
                inspection.ClaimNote = chaxunInfo.ClaimNote;
                inspection.BondsState = chaxunInfo.BondsState;
                inspection.BondsNote = chaxunInfo.BondsNote;
                inspection.ViolationState = chaxunInfo.ViolationState;
                inspection.ViolationNote = chaxunInfo.ViolationNote;

                @case.State = State.Baojia;
                this.RecordTime(@case, State.Chaxun);

                await db.ExecuteSaveChangesAsync();

                return @case;
            }
        }
Exemplo n.º 12
0
        /// <summary>
        ///     add special case as an asynchronous operation.
        /// </summary>
        /// <param name="case">The case.</param>
        /// <param name="info">The information.</param>
        /// <param name="photos">The photos.</param>
        /// <returns>Task&lt;CaseDto&gt;.</returns>
        /// <exception cref="ApplicationException">无法加载用户信息</exception>
        /// <exception cref="System.ApplicationException">无法加载用户信息</exception>
        private async Task<Case> AddSpecialCaseAsync(Case @case, VehicleInfo info, IEnumerable<int> photos)
        {
            Case newCase = new Case
            {
                Abandon = false,
                AbandonReason = "",
                CaseType = @case.CaseType,
                DirectorId = null, // need update
                ManagerId = null,
                OutletId = 0, // need update
                PurchasePrice = 0,
                PurchaserId = @case.PurchaserId,
                QueryingId = null,
                SerialId = @case.SerialId,
                State = State.Shenhe,
                ValuerId = null,
                VehicleInfoId = 0, // need update
                VehicleInspecId = 0, // need update
                CreateTime = DateTime.UtcNow.AddHours(8)
            };

            VehicleInfo newInfo = new VehicleInfo
            {
                BrandName = info.BrandName,
                CooperationMethod = info.CooperationMethod,
                DisplayMileage = info.DisplayMileage,
                ExpectedPrice = info.ExpectedPrice,
                FactoryTime = info.FactoryTime,
                InnerColor = info.InnerColor,
                InnerColorName = info.InnerColorName,
                LicenseLocation = info.LicenseLocation,
                LicenseTime = info.LicenseTime,
                ModelId = info.ModelId,
                ModelName = info.ModelName,
                ModifiedContent = info.ModifiedContent,
                OuterColor = info.OuterColor,
                OuterColorName = info.OuterColorName,
                SeriesName = info.SeriesName,
                VehicleLocation = info.VehicleLocation
            };

            VehicleInspection newVehicleInspection = new VehicleInspection();

            int purchaserId = @case.PurchaserId;
            using (ChePingContext db = new ChePingContext())
            {
                await db.SaveAsync(newInfo);

                await db.SaveAsync(newVehicleInspection);

                User user = await db.Users.FirstOrDefaultAsync(u => u.Id == purchaserId && u.JobTitle == JobTitle.Purchaser && u.Available);
                if (user == null)
                {
                    throw new ApplicationException("无法加载用户信息");
                }

                List<User> directors = await db.Users.Where(u => u.Available && u.OutletId == user.OutletId && u.JobTitle == JobTitle.Director).ToListAsync();

                int caseCount = await db.Cases.CountAsync(c => c.OutletId == user.OutletId && DirectorTodoStates.Contains(c.State) && c.DirectorId != null);
                int index = caseCount % directors.Count;

                int directorId = directors[index].Id;

                newCase.DirectorId = directorId;
                newCase.OutletId = user.OutletId;
                newCase.VehicleInfoId = newInfo.Id;
                newCase.VehicleInspecId = newVehicleInspection.Id;

                await db.SaveAsync(newCase);

                foreach (int photo in photos)
                {
                    Photo photoModel = await db.Photos.FirstOrDefaultAsync(p => p.Id == photo);

                    if (photoModel != null)
                    {
                        photoModel.CaseId = newCase.Id;
                    }
                }

                await db.ExecuteSaveChangesAsync();
            }

            return newCase;
        }
Exemplo n.º 13
0
        /// <summary>
        ///     add general case as an asynchronous operation.
        /// </summary>
        /// <param name="case">The case.</param>
        /// <param name="info">The information.</param>
        /// <param name="photos">The photos.</param>
        /// <returns>System.Threading.Tasks.Task&lt;ChepingServer.Models.Case&gt;.</returns>
        /// <exception cref="ApplicationException">
        ///     无法加载用户信息
        ///     or
        ///     无在岗评估师,事项添加失败
        ///     or
        ///     评估师分配错误,事项添加失败
        /// </exception>
        /// <exception cref="System.ApplicationException">
        ///     无法加载车型信息
        ///     or
        ///     无法加载用户信息
        ///     or
        ///     无在岗评估师,事项添加失败
        ///     or
        ///     评估师分配错误,事项添加失败
        /// </exception>
        private async Task<Case> AddGeneralCaseAsync(Case @case, VehicleInfo info, IEnumerable<int> photos)
        {
            Case newCase = new Case
            {
                Abandon = false,
                AbandonReason = "",
                CaseType = @case.CaseType,
                DirectorId = null,
                ManagerId = null,
                OutletId = 0, // need update
                PurchasePrice = 0,
                PurchaserId = @case.PurchaserId,
                QueryingId = null,
                SerialId = @case.SerialId,
                State = State.Pinggu,
                ValuerId = null, // need update
                VehicleInfoId = 0, // need update
                VehicleInspecId = 0, // need update
                CreateTime = DateTime.UtcNow.AddHours(8),
                Times = null
            };

            VehicleInfo newInfo = new VehicleInfo
            {
                BrandName = info.BrandName,
                CooperationMethod = info.CooperationMethod,
                DisplayMileage = info.DisplayMileage,
                ExpectedPrice = info.ExpectedPrice,
                FactoryTime = info.FactoryTime,
                InnerColor = info.InnerColor,
                InnerColorName = info.InnerColorName,
                LicenseLocation = info.LicenseLocation,
                LicenseTime = info.LicenseTime,
                ModelId = info.ModelId,
                ModelName = info.ModelName,
                ModifiedContent = info.ModifiedContent,
                OuterColor = info.OuterColor,
                OuterColorName = info.OuterColorName,
                SeriesName = info.SeriesName,
                VehicleLocation = info.VehicleLocation
            };

            VehicleInspection newVehicleInspection = new VehicleInspection();

            int purchaserId = @case.PurchaserId;
            using (ChePingContext db = new ChePingContext())
            {
                await db.SaveAsync(newInfo);

                await db.SaveAsync(newVehicleInspection);

                User user = await db.Users.FirstOrDefaultAsync(u => u.Id == purchaserId && u.JobTitle == JobTitle.Purchaser && u.Available);
                if (user == null)
                {
                    throw new ApplicationException("无法加载用户信息");
                }

                int valuerId;
                List<User> valuers = await db.Users.Where(u => u.Available && !u.HangOn && u.JobTitle == JobTitle.Valuer && u.ValuerGroup.Contains(((int)newCase.CaseType).ToString())).ToListAsync();

                var workingValuers = await db.Cases.Where(c => ValuerTodoStates.Contains(c.State) && c.ValuerId != null)
                    .GroupBy(c => c.ValuerId).Select(g => new { g.Key, Count = g.Count() }).ToListAsync();

                valuers.RemoveAll(v => workingValuers.Select(i => i.Key).Contains(v.Id));

                if (valuers.Count > 0)
                {
                    valuerId = valuers[0].Id;
                }
                else
                {
                    if (workingValuers.Count == 0)
                    {
                        throw new ApplicationException("无在岗评估师,事项添加失败");
                    }

                    valuerId = workingValuers.OrderBy(v => v.Count).Select(v => v.Key).First().GetValueOrDefault();

                    if (valuerId == 0)
                    {
                        throw new ApplicationException("评估师分配错误,事项添加失败");
                    }
                }

                newCase.ValuerId = valuerId;
                newCase.OutletId = user.OutletId;
                newCase.VehicleInfoId = newInfo.Id;
                newCase.VehicleInspecId = newVehicleInspection.Id;

                await db.SaveAsync(newCase);

                foreach (int photo in photos)
                {
                    Photo photoModel = await db.Photos.FirstOrDefaultAsync(p => p.Id == photo);

                    if (photoModel != null)
                    {
                        photoModel.CaseId = newCase.Id;
                    }
                }

                await db.ExecuteSaveChangesAsync();

                await this.smsService.SendNoticeMessage(newCase.ValuerId.GetValueOrDefault());
            }

            return newCase;
        }
Exemplo n.º 14
0
        /// <summary>
        ///     review case as an asynchronous operation.
        /// </summary>
        /// <param name="caseId">The case identifier.</param>
        /// <param name="purchasePrice">The purchase price.</param>
        /// <returns>Task&lt;Case&gt;.</returns>
        public async Task<Case> ReviewCaseAsync(int caseId, int purchasePrice)
        {
            using (ChePingContext db = new ChePingContext())
            {
                Case @case = await db.Cases.FirstOrDefaultAsync(c => c.Id == caseId);
                if (@case == null)
                {
                    throw new ApplicationException("未能加载事项信息");
                }

                if (@case.State == State.Shenhe)
                {
                    @case.PurchasePrice = purchasePrice;
                    @case.State = State.Yanche;
                    this.RecordTime(@case, State.Shenhe);
                    await db.ExecuteSaveChangesAsync();
                }

                if (@case.State == State.Baojia)
                {
                    @case.PurchasePrice = purchasePrice;
                    @case.State = State.Qiatan;
                    this.RecordTime(@case, State.Baojia);
                    await db.ExecuteSaveChangesAsync();
                }

                await this.smsService.SendNoticeMessage(@case.PurchaserId);

                return @case;
            }
        }
Exemplo n.º 15
0
        /// <summary>
        ///     Rejections the confirm.
        /// </summary>
        /// <param name="caseId">The case identifier.</param>
        /// <returns>Task&lt;Case&gt;.</returns>
        /// <exception cref="System.ApplicationException">未能加载事项信息</exception>
        public async Task<Case> RejectionConfirmAsync(int caseId)
        {
            using (ChePingContext db = new ChePingContext())
            {
                Case @case = await db.Cases.FirstOrDefaultAsync(c => c.Id == caseId);
                if (@case == null)
                {
                    throw new ApplicationException("未能加载事项信息");
                }

                if (@case.Abandon == false)
                {
                    @case.Abandon = true;
                    await db.ExecuteSaveChangesAsync();
                }

                return @case;
            }
        }