public EqManagerEditDto GetInfo(Guid id) { var processes = this._processManagementRepository.Get(r => r.PurchaseId == id); var result = new EqManagerEditDto() { PlanId = id, Unit1 = processes.FirstOrDefault(r => r.Type == DictionaryCategory.Purchase_BiddingAgency).Unit, Unit2 = processes.FirstOrDefault(r => r.Type == DictionaryCategory.Purchase_ConstructionControlUnit) .Unit, Unit3 = processes.FirstOrDefault(r => r.Type == DictionaryCategory.Purchase_CostUnit).Unit, Unit4 = processes.FirstOrDefault(r => r.Type == DictionaryCategory.Purchase_DesignUnit).Unit, Unit5 = this._bidOpeningManagementRepository.FirstOrDefault(r => r.PlanId == id).SuccessfulTender }; result.UnitName1 = this._sysDictionaryRepository.Get(result.Unit1.Value).Value; result.UnitName2 = this._sysDictionaryRepository.Get(result.Unit2.Value).Value; result.UnitName3 = this._sysDictionaryRepository.Get(result.Unit3.Value).Value; result.UnitName4 = this._sysDictionaryRepository.Get(result.Unit4.Value).Value; return(result); }
public async Task SaveAsync(EqManagerEditDto input) { if (this._eqManagerRepository.Any(r => (!input.Id.HasValue && r.PlanId == input.PlanId) || (input.Id.HasValue && r.Id != input.Id && r.PlanId == input.PlanId))) { throw new UserFriendlyException("采购计划已添加"); } var item = input.MapTo <EqManager>(); if (!input.Id.HasValue) { await this._eqManagerRepository.InsertAsync(item); } else { var old = this._eqManagerRepository.Get(input.Id.Value); Mapper.Map(input, old); await this._eqManagerRepository.UpdateAsync(old); } var currentYearItem = this._sysDictionaryRepository.FirstOrDefault(r => r.Value4 == true.ToString() && r.Category == DictionaryCategory.Budget_Year); var year = int.Parse(currentYearItem.Value); var scoreLevel = this._sysDictionaryRepository .Get(r => r.Category == DictionaryCategory.Purchase_SystemScore).FirstOrDefault(); var baseScore = decimal.Parse(scoreLevel.Value3); if (item.Score1 <= baseScore) { this._blacklistRepository.Insert(new Blacklist() { Name = input.Unit1.Value.ToString(), Type = DictionaryCategory.Purchase_BiddingAgency, Year = year }); } if (item.Score2 <= baseScore) { this._blacklistRepository.Insert(new Blacklist() { Name = input.Unit2.Value.ToString(), Type = DictionaryCategory.Purchase_ConstructionControlUnit, Year = year }); } if (item.Score3 <= baseScore) { this._blacklistRepository.Insert(new Blacklist() { Name = input.Unit3.Value.ToString(), Type = DictionaryCategory.Purchase_CostUnit, Year = year }); } if (item.Score4 <= baseScore) { this._blacklistRepository.Insert(new Blacklist() { Name = input.Unit4.Value.ToString(), Type = DictionaryCategory.Purchase_DesignUnit, Year = year }); } if (item.Score5 <= baseScore) { this._blacklistRepository.Insert(new Blacklist() { Name = input.Unit5, Type = DictionaryCategory.Purchase_Supplier, Year = year }); } }