Ejemplo n.º 1
0
        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);
            }
        }
Ejemplo n.º 2
0
 public Models.ShippingArea GetById(Guid id)
 {
     using (var dbContext = new LogisticsDbContext())
     {
         var model = dbContext.ShippingAreas.FirstOrDefault(g => g.Id.Equals(id));
         return(model);
     }
 }
Ejemplo n.º 3
0
 public Models.ShippingAreaFee GetFeeByAreaId(string areaId)
 {
     using (var dbContext = new LogisticsDbContext())
     {
         var model = dbContext.ShippingAreasFees.FirstOrDefault(g => g.AreaId.Equals(areaId));
         return(model);
     }
 }
Ejemplo n.º 4
0
 public Models.ShippingArea GetDefaultShippingArea()
 {
     using (var dbContext = new LogisticsDbContext())
     {
         var mod = dbContext.ShippingAreas.FirstOrDefault(g => g.IsDefualt == Models.DefaultStatus.Default);
         return(mod);
     }
 }
Ejemplo n.º 5
0
 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);
     }
 }
Ejemplo n.º 6
0
 public List <Models.ShippingAreaFee> GetFeeListByShippingAreaId(Guid shippingAreaId)
 {
     using (var dbContext = new LogisticsDbContext())
     {
         var query =
             dbContext.ShippingAreasFees.Where(me => me.ShippingAreaId == shippingAreaId);
         return(query.ToList());
     }
 }
Ejemplo n.º 7
0
 public OrderAppService(IRepository <Order, Guid> repository,
                        IRepository <DataDic, Guid> datadicRepository,
                        IRepository <User, long> userRepository,
                        LogisticsDbContext context)
 {
     _context           = context;
     _userRepository    = userRepository;
     _datadicRepository = datadicRepository;
     _Repository        = repository;
 }
Ejemplo n.º 8
0
 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());
     }
 }
Ejemplo n.º 9
0
        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);
            }
        }
Ejemplo n.º 10
0
 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();
     }
 }
Ejemplo n.º 11
0
 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);
     }
 }
Ejemplo n.º 12
0
 public PathService(LogisticsDbContext db)
 {
     Db = db;
 }
Ejemplo n.º 13
0
 public AddressesController(LogisticsDbContext dbContext)
 {
     this.dbContext = dbContext;
 }
Ejemplo n.º 14
0
 public CityService(LogisticsDbContext db)
 {
     this.Db = db;
 }
Ejemplo n.º 15
0
 public LogisticCenterService(LogisticsDbContext db, ICityService cities, IPathService paths)
 {
     Db          = db;
     this.cities = cities;
     this.paths  = paths;
 }