public bool SaveInfo(Models.ShippingArea model, List <Models.ShippingAreaFee> feeList, bool insert = true) { using (var dbContext = new LogisticsDbContext()) { if (insert) { model.CreateTime = DateTime.Now; model.LastUpdateTime = DateTime.Now; model.Status = Models.ShippingAreaStatus.Normal; dbContext.ShippingAreas.Add(model); } else { model.LastUpdateTime = DateTime.Now; dbContext.ShippingAreas.Attach(model); dbContext.Entry(model).State = EntityState.Modified; //批量删除区域费用 _currencyService.DeleteByConditon <Models.ShippingAreaFee>(d => d.ShippingAreaId == model.Id); } foreach (var feeInfo in feeList) { dbContext.ShippingAreasFees.Add(feeInfo); } var result = dbContext.SaveChanges() > 0; if (result) { Logger.Operation($"编辑配送区域-{model.Name}:{model.Id}", LogisticsModule.Instance); } return(result); } }
public Models.ShippingArea GetById(Guid id) { using (var dbContext = new LogisticsDbContext()) { var model = dbContext.ShippingAreas.FirstOrDefault(g => g.Id.Equals(id)); return(model); } }
public Models.ShippingAreaFee GetFeeByAreaId(string areaId) { using (var dbContext = new LogisticsDbContext()) { var model = dbContext.ShippingAreasFees.FirstOrDefault(g => g.AreaId.Equals(areaId)); return(model); } }
public Models.ShippingArea GetDefaultShippingArea() { using (var dbContext = new LogisticsDbContext()) { var mod = dbContext.ShippingAreas.FirstOrDefault(g => g.IsDefualt == Models.DefaultStatus.Default); return(mod); } }
public Models.ShippingAreaFee NotShippingArea(string areaId) { using (var dbContext = new LogisticsDbContext()) { var mod = dbContext.ShippingAreasFees.FirstOrDefault(g => g.AreaId.Equals(areaId) && g.IsDefualt == Models.DefaultStatus.NotShipping); return(mod); } }
public List <Models.ShippingAreaFee> GetFeeListByShippingAreaId(Guid shippingAreaId) { using (var dbContext = new LogisticsDbContext()) { var query = dbContext.ShippingAreasFees.Where(me => me.ShippingAreaId == shippingAreaId); return(query.ToList()); } }
public OrderAppService(IRepository <Order, Guid> repository, IRepository <DataDic, Guid> datadicRepository, IRepository <User, long> userRepository, LogisticsDbContext context) { _context = context; _userRepository = userRepository; _datadicRepository = datadicRepository; _Repository = repository; }
public List <Shipping> GetList() { using (var dbContext = new LogisticsDbContext()) { var query = dbContext.Shippings.Where(me => me.Status > 0) .OrderByDescending(me => me.CreateTime); return(query.ToList()); } }
public List <Models.ShippingArea> GetListPaged <TKey>(int pageIndex, int pageSize, Expression <Func <Models.ShippingArea, bool> > expression, Expression <Func <Models.ShippingArea, TKey> > orderByExpression, bool isDesc, out int totalCount) { using (var dbContext = new LogisticsDbContext()) { var query = dbContext.ShippingAreas.Where(expression); totalCount = query.Count(); query = isDesc ? query.OrderByDescending(orderByExpression) : query.OrderBy(orderByExpression); var list = query.Skip((pageIndex - 1) * pageSize).Take(pageSize).ToList(); return(list); } }
public void SetDefault(Guid shippingId) { using (var dbContext = new LogisticsDbContext()) { var defaultList = dbContext.Shippings.Where(me => me.IsDefault || me.Id.Equals(shippingId)).ToList(); foreach (Shipping shipping in defaultList) { shipping.IsDefault = shipping.Id.Equals(shippingId)? true:false; } dbContext.SaveChanges(); } }
public bool Create(Models.ShippingArea model) { using (var dbContext = new LogisticsDbContext()) { model.Id = KeyGenerator.GetGuidKey(); model.CreateTime = DateTime.Now; model.LastUpdateTime = DateTime.Now; model.Status = Models.ShippingAreaStatus.Normal; dbContext.ShippingAreas.Add(model); var result = dbContext.SaveChanges() > 0; if (result) { Logger.Operation($"创建配送区域-{model.Name}:{model.Id}", LogisticsModule.Instance); } return(result); } }
public PathService(LogisticsDbContext db) { Db = db; }
public AddressesController(LogisticsDbContext dbContext) { this.dbContext = dbContext; }
public CityService(LogisticsDbContext db) { this.Db = db; }
public LogisticCenterService(LogisticsDbContext db, ICityService cities, IPathService paths) { Db = db; this.cities = cities; this.paths = paths; }