示例#1
0
        public static DeclerationDb Creaet(int UserId, CreateDeclerationView create)
        {
            DeclerationDb dec = new DeclerationDb();

            create.ViewFromDb(dec);
            dec.OrderPrice  = create.OrderPrice * create.BundleCount;
            dec.InvoicePath = dec.SaveImageFileGeneral(create.Invoice, "/Image/Decleration");
            dec.OrderDate   = DateTime.Parse(create.DecDate);
            dec.UserDbId    = UserId;
            if (create.OrderDbId != null)
            {
                using (CargoDbContext db = new CargoDbContext())
                {
                    var Order = db.Orders.FirstOrDefault(f => f.Id == create.OrderDbId && f.UserDbId == UserId);
                    if (Order != null)
                    {
                        Order.Ordered = true;
                    }
                    else
                    {
                        Order.Ordered = false;
                    }
                }
            }

            return(dec);
        }
示例#2
0
 public static int UserMsgCount(int?id)
 {
     using (CargoDbContext db = new CargoDbContext())
     {
         int unread = db.Messages.Count(f => f.ToMesssageUserDbId == id && f.Read == false);
         return(unread);
     }
 }
示例#3
0
        public static async Task <List <OrderDb> > IsNotPaid()
        {
            using (CargoDbContext db = new CargoDbContext())
            {
                var OrderListist = await db.Orders.Where(w => w.isPaid == false).ToListAsync();

                return(OrderListist);
            }
        }
示例#4
0
        //==================================================================
        ///IsPaid

        public static async Task <List <OrderDb> > IsPaid(int?Userid)
        {
            using (CargoDbContext db = new CargoDbContext())
            {
                var OrderListist = await db.Orders.Where(w => w.isPaid == true && w.UserDbId == Userid).ToListAsync();

                return(OrderListist);
            }
        }
示例#5
0
        public static async Task <List <OrderDb> > Ordered()
        {
            using (CargoDbContext db = new CargoDbContext())
            {
                var OrderListist = await db.Orders.Where(w => w.Ordered == true).ToListAsync();

                return(OrderListist);
            }
        }
示例#6
0
        //==================================================================
        ///Normal

        public static async Task <List <OrderDb> > Normal(int?Userid)
        {
            using (CargoDbContext db = new CargoDbContext())
            {
                var OrderListist = await db.Orders.Where(w => w.isUrgent == false && w.UserDbId == Userid).ToListAsync();

                return(OrderListist);
            }
        }
示例#7
0
        /// /////////////////////////////////////////////////////////////

        public static int AdminMsgCount()
        {
            int unread = 0;

            using (CargoDbContext db = new CargoDbContext())
            {
                unread = db.Messages.Count(f => f.ToMesssageUserDbId == null && f.UserDbId != null && f.Read == false);
                return(unread);
            }
        }
示例#8
0
        public static BalanceOperator ChangeBalance(UserDb user, decimal AddBalance, CargoDbContext db)
        {
            user.Balance += (AddBalance);

            BalanceOperator Bo = new BalanceOperator()
            {
                Total = user.Balance, OutIn = AddBalance, UserDbId = user.Id, Date = DateTime.Now
            };

            return(Bo);
        }
示例#9
0
        public static async Task <bool> Delete(DeleteOrder delete, CargoDbContext db)
        {
            var del = await db.Orders.FirstOrDefaultAsync(f => f.Id == delete.OrderId && f.UserDbId == delete.UserId);

            if (del != null)
            {
                db.Orders.Remove(del);
                return(true);
            }
            else
            {
                return(false);
            }
        }
示例#10
0
        public static async Task <bool> Delete(int id, CargoDbContext db)
        {
            int?SesId = (int)HttpContext.Current.Session["userId"];

            var del = await db.Orders.FirstOrDefaultAsync(f => f.Id == id && f.UserDbId == SesId);

            if (del != null)
            {
                db.Orders.Remove(del);
                return(true);
            }
            else
            {
                return(false);
            }
        }
示例#11
0
        public static decimal SelectTa(int Id, decimal Weight)
        {
            decimal WeightPrice;

            using (CargoDbContext db = new CargoDbContext())
            {
                var tarif            = db.Tarifs.Where(w => w.CountryId == Id);
                var CountryMaxWeight = tarif.Max(m => m.MaxWeight);
                if (Weight > CountryMaxWeight)
                {
                    var CountryMaxTarif = tarif.FirstOrDefault(f => f.MaxWeight == CountryMaxWeight);
                    WeightPrice = CountryMaxTarif.WeightPrice;
                }
                else
                {
                    WeightPrice = tarif.FirstOrDefault(f => f.MaxWeight >= Weight).WeightPrice;
                }
            }
            return(WeightPrice);
        }
示例#12
0
        //????????
        public static GetIndexBundel Create(BundelsDb bundel)
        {
            GetIndexBundel gt = new GetIndexBundel();

            bundel.ViewFromDb(gt);
            Task task1 = Task.Run(() =>
            {
                using (CargoDbContext dbs = new CargoDbContext())
                {
                    gt.CountryName = dbs.Countries.AsParallel().FirstOrDefault(f => f.Id == bundel.CountryId).CauntryName;
                    var orders     = dbs.Orders.AsParallel().Where(w => w.BundelsDbId == bundel.Id).ToList();
                    if (orders != null)
                    {
                        for (var i = 0; i < orders.Count; i++)
                        {
                            gt.Links.Add(new BundelLinks(orders[i]));
                        }
                    }
                }
            });

            Task task2 = Task.Run(() =>
            {
                using (CargoDbContext dbs = new CargoDbContext())
                {
                    gt.CountryName = dbs.Countries.AsParallel().FirstOrDefault(f => f.Id == bundel.CountryId).CauntryName;
                    var decs       = dbs.Declerations.AsParallel().Where(w => w.BundelsDbId == bundel.Id).ToList();
                    if (decs != null)
                    {
                        for (var i = 0; i < decs.Count; i++)
                        {
                            gt.Links.Add(new BundelLinks(decs[i]));
                        }
                    }
                }
            });

            Task.WaitAll(task1, task2);

            return(gt);
        }
示例#13
0
        public static void AddOrder(string OrderName, int BundelId, CargoDbContext db)
        {
            int    id    = int.Parse(OrderName.Substring(0, OrderName.IndexOf("-")));
            string order = OrderName.Substring(OrderName.IndexOf("-") + 1);

            if (order.ToUpper() == "order".ToUpper())
            {
                var orderDb = db.Orders.FirstOrDefault(f => f.Id == id && f.BundelsDbId == 0 && f.Executed == false && f.Ordered == true && f.isPaid == true);
                if (orderDb != null)
                {
                    orderDb.Executed    = true;
                    orderDb.BundelsDbId = BundelId;
                }
            }
            else
            {
                var DecDb = db.Declerations.FirstOrDefault(f => f.Id == id && f.BundelsDbId == 0 && f.Executed == false && f.CreatAdmin == false && f.IsForeignWarehouse == true);
                if (DecDb != null)
                {
                    DecDb.Executed    = true;
                    DecDb.BundelsDbId = BundelId;
                }
            }
        }
示例#14
0
 public FeaturesController(CargoDbContext context, IMapper mapper)
 {
     this.mapper  = mapper;
     this.context = context;
 }
示例#15
0
        //==============================================================================
        //is not decleration
        public static async Task <List <OrderDb> > IsNotDecleration(int?Userid, CargoDbContext db)
        {
            var OrderListist = await db.Orders.Where(w => w.Ordered == false && w.UserDbId == Userid).ToListAsync();

            return(OrderListist);
        }