public IList <ExpenseLineConfirmHistoryExportDto> GetExpenseHistory(int expenseType, string period) { //根据不同的费用类型,进行适配转换 ITarget adapter = new Adapter.Adapter(_crmDbContext, _mapper, expenseType, period); var entities = adapter.Transform(); var models = _mapper.Map <List <ExpenseLineConfirmHistoryExportDto> >(entities); return(models); //var models = _expenseHistoryRepository.Where(s => s.Period == period).Select(s => _mapper.Map<ExpenseLineConfirmHistoryExportDto>(s)).ToList(); //return models; }
/// <summary> /// 费用----添加---拆分前 /// </summary> /// <param name="expenseType">费用类型</param> /// <param name="expenseCode"></param> /// <param name="period"></param> /// <returns></returns> public bool AddExpenseAccount(int expenseType, string expenseCode = "", string period = null) { //根据不同的费用类型,进行适配转换 ITarget adapter = new Adapter.Adapter(_crmDbContext, _mapper, expenseType, period, expenseCode); var entities = adapter.Transform(); //如果有部门为空 var count = entities.Count(s => string.IsNullOrEmpty(s.DepartID)); if (count > 0) { return(false); } entities.ToList().ForEach(s => { s.Id = 0; s.LastUpdateTime = DateTime.Now; s.CreateTime = DateTime.Now; s.Step = (int)CommonEnum.EnumCostAccountSplitStep.BeforeSplit; }); using (var uow = _uowCrm.Create()) { Expression <Func <ExpenseAccount, bool> > expTem = s => s.Status == 0 && s.Period == period && s.ExpenseType == expenseType; if (!string.IsNullOrEmpty(expenseCode)) { expTem = expTem.And(s => s.ExpenseCode == expenseCode); } var n = _expenseAccountRepository.UpdateWhere(expTem , new ExpenseAccount() { Status = -1, LastUpdateTime = DateTime.Now }, t => t.Status, t => t.LastUpdateTime); var i = _expenseAccountRepository.Add(entities); uow.SaveChanges(); return(true); } }