public bool FinishOrder(string orderid)
        {
            var order = _context.Orders.FirstOrDefault(o => o.OrderId == orderid);

            order.Status = 1;
            _context.Update(order);
            _context.SaveChanges();
            //PrintTicket(order.OrderId);
            return(true);
        }
Пример #2
0
        public JsonResult ResetPwd(int?id)
        {
            ResetPwdModel resetPwdModel = null;

            if (!IsSafe())
            {
                resetPwdModel = new ResetPwdModel()
                {
                    Code    = 519,
                    Message = "管理员账号状态存在异常,请联系运维人员"
                };
                return(Json(resetPwdModel));
            }

            var admin = _context.Admin.FirstOrDefault(a => a.Id == id);

            if (admin == null)
            {
                resetPwdModel = new ResetPwdModel()
                {
                    Code    = 518,
                    Message = "该用户状态异常,请联系运维人员"
                };
                return(Json(resetPwdModel));
            }

            string password     = PassWordHelper.GenerateCheckCode(8);
            string database_pwd = PassWordHelper.Md532Salt(password, admin.LoginAccount);

            admin.PassWord = database_pwd;
            _context.Update(admin);
            _context.SaveChanges();

            resetPwdModel = new ResetPwdModel()
            {
                Code    = 520,
                Message = $"密码重置成功,该管理员密码为{password},请妥善保管",
                NewPwd  = database_pwd
            };
            return(Json(resetPwdModel));
        }
Пример #3
0
        public static void Initialize(IServiceProvider serviceProvider)
        {
            using (var context = new FitNightSnackMgrContext(
                       serviceProvider.GetRequiredService <
                           DbContextOptions <FitNightSnackMgrContext> >()))
            {
                // Look for any Admin.
                if (!context.Admin.Any())
                {
                    context.Admin.AddRange(
                        new Admin()
                    {
                        LoginAccount = "admin", AdminName = "刘德华", PassWord = "******", CreateTime = DateTime.Now, Permissions = 0
                    },
                        new Admin()
                    {
                        LoginAccount = "worker1", AdminName = "蔡徐坤", PassWord = "******", CreateTime = DateTime.Now, Permissions = 1
                    },
                        new Admin()
                    {
                        LoginAccount = "worker2", AdminName = "罗志祥", PassWord = "******", CreateTime = DateTime.Now, Permissions = 1
                    }
                        );
                    context.SaveChanges();
                }


                // Look for any User.
                if (!context.User.Any())
                {
                    context.User.AddRange(
                        new User()
                    {
                        UserAccount = "666666666", Password = "******", Money = 100, Phone = "139139139", Address = "A4-405", UserName = "******", Status = 1
                    },
                        new User()
                    {
                        UserAccount = "77777777777", Password = "******", Money = 100, Phone = "139139139", Address = "A4-406", UserName = "******", Status = 1
                    },
                        new User()
                    {
                        UserAccount = "888888", Password = "******", Money = 100, Phone = "139139139", Address = "A4-407", UserName = "******", Status = 0
                    },
                        new User()
                    {
                        UserAccount = "899999", Password = "******", Money = 100, Phone = "139139139", Address = "A4-408", UserName = "******", Status = 0
                    },
                        new User()
                    {
                        UserAccount = "11111111", Password = "******", Money = 100, Phone = "139139139", Address = "A4-409", UserName = "******", Status = 1
                    },
                        new User()
                    {
                        UserAccount = "11111111", Password = "******", Money = 100, Phone = "139139139", Address = "A4-409", UserName = "******", Status = 1
                    }, new User()
                    {
                        UserAccount = "11111111", Password = "******", Money = 100, Phone = "139139139", Address = "A4-409", UserName = "******", Status = 1
                    }, new User()
                    {
                        UserAccount = "11111111", Password = "******", Money = 100, Phone = "139139139", Address = "A4-409", UserName = "******", Status = 1
                    }, new User()
                    {
                        UserAccount = "11111111", Password = "******", Money = 100, Phone = "139139139", Address = "A4-409", UserName = "******", Status = 1
                    }, new User()
                    {
                        UserAccount = "11111111", Password = "******", Money = 100, Phone = "139139139", Address = "A4-409", UserName = "******", Status = 1
                    }, new User()
                    {
                        UserAccount = "11111111", Password = "******", Money = 100, Phone = "139139139", Address = "A4-409", UserName = "******", Status = 1
                    }, new User()
                    {
                        UserAccount = "11111111", Password = "******", Money = 100, Phone = "139139139", Address = "A4-409", UserName = "******", Status = 1
                    }, new User()
                    {
                        UserAccount = "11111111", Password = "******", Money = 100, Phone = "139139139", Address = "A4-409", UserName = "******", Status = 1
                    }, new User()
                    {
                        UserAccount = "11111111", Password = "******", Money = 100, Phone = "139139139", Address = "A4-409", UserName = "******", Status = 1
                    }, new User()
                    {
                        UserAccount = "11111111", Password = "******", Money = 100, Phone = "139139139", Address = "A4-409", UserName = "******", Status = 1
                    }, new User()
                    {
                        UserAccount = "11111111", Password = "******", Money = 100, Phone = "139139139", Address = "A4-409", UserName = "******", Status = 1
                    }, new User()
                    {
                        UserAccount = "11111111", Password = "******", Money = 100, Phone = "139139139", Address = "A4-409", UserName = "******", Status = 1
                    }, new User()
                    {
                        UserAccount = "11111111", Password = "******", Money = 100, Phone = "139139139", Address = "A4-409", UserName = "******", Status = 1
                    }, new User()
                    {
                        UserAccount = "11111111", Password = "******", Money = 100, Phone = "139139139", Address = "A4-409", UserName = "******", Status = 1
                    }, new User()
                    {
                        UserAccount = "11111111", Password = "******", Money = 100, Phone = "139139139", Address = "A4-409", UserName = "******", Status = 1
                    }, new User()
                    {
                        UserAccount = "11111111", Password = "******", Money = 100, Phone = "139139139", Address = "A4-409", UserName = "******", Status = 1
                    }, new User()
                    {
                        UserAccount = "11111111", Password = "******", Money = 100, Phone = "139139139", Address = "A4-409", UserName = "******", Status = 1
                    }, new User()
                    {
                        UserAccount = "11111111", Password = "******", Money = 100, Phone = "139139139", Address = "A4-409", UserName = "******", Status = 1
                    }, new User()
                    {
                        UserAccount = "11111111", Password = "******", Money = 100, Phone = "139139139", Address = "A4-409", UserName = "******", Status = 1
                    }, new User()
                    {
                        UserAccount = "11111111", Password = "******", Money = 100, Phone = "139139139", Address = "A4-409", UserName = "******", Status = 1
                    }, new User()
                    {
                        UserAccount = "11111111", Password = "******", Money = 100, Phone = "139139139", Address = "A4-409", UserName = "******", Status = 1
                    }, new User()
                    {
                        UserAccount = "11111111", Password = "******", Money = 100, Phone = "139139139", Address = "A4-409", UserName = "******", Status = 1
                    }, new User()
                    {
                        UserAccount = "11111111", Password = "******", Money = 100, Phone = "139139139", Address = "A4-409", UserName = "******", Status = 1
                    }, new User()
                    {
                        UserAccount = "11111111", Password = "******", Money = 100, Phone = "139139139", Address = "A4-409", UserName = "******", Status = 1
                    }, new User()
                    {
                        UserAccount = "11111111", Password = "******", Money = 100, Phone = "139139139", Address = "A4-409", UserName = "******", Status = 1
                    }, new User()
                    {
                        UserAccount = "11111111", Password = "******", Money = 100, Phone = "139139139", Address = "A4-409", UserName = "******", Status = 1
                    }, new User()
                    {
                        UserAccount = "11111111", Password = "******", Money = 100, Phone = "139139139", Address = "A4-409", UserName = "******", Status = 1
                    }, new User()
                    {
                        UserAccount = "11111111", Password = "******", Money = 100, Phone = "139139139", Address = "A4-409", UserName = "******", Status = 1
                    }, new User()
                    {
                        UserAccount = "11111111", Password = "******", Money = 100, Phone = "139139139", Address = "A4-409", UserName = "******", Status = 1
                    }, new User()
                    {
                        UserAccount = "11111111", Password = "******", Money = 100, Phone = "139139139", Address = "A4-409", UserName = "******", Status = 1
                    }, new User()
                    {
                        UserAccount = "11111111", Password = "******", Money = 100, Phone = "139139139", Address = "A4-409", UserName = "******", Status = 1
                    }, new User()
                    {
                        UserAccount = "11111111", Password = "******", Money = 100, Phone = "139139139", Address = "A4-409", UserName = "******", Status = 1
                    }, new User()
                    {
                        UserAccount = "11111111", Password = "******", Money = 100, Phone = "139139139", Address = "A4-409", UserName = "******", Status = 1
                    }, new User()
                    {
                        UserAccount = "11111111", Password = "******", Money = 100, Phone = "139139139", Address = "A4-409", UserName = "******", Status = 1
                    }, new User()
                    {
                        UserAccount = "11111111", Password = "******", Money = 100, Phone = "139139139", Address = "A4-409", UserName = "******", Status = 1
                    }, new User()
                    {
                        UserAccount = "11111111", Password = "******", Money = 100, Phone = "139139139", Address = "A4-409", UserName = "******", Status = 1
                    }, new User()
                    {
                        UserAccount = "11111111", Password = "******", Money = 100, Phone = "139139139", Address = "A4-409", UserName = "******", Status = 1
                    }, new User()
                    {
                        UserAccount = "11111111", Password = "******", Money = 100, Phone = "139139139", Address = "A4-409", UserName = "******", Status = 1
                    }, new User()
                    {
                        UserAccount = "11111111", Password = "******", Money = 100, Phone = "139139139", Address = "A4-409", UserName = "******", Status = 1
                    }, new User()
                    {
                        UserAccount = "11111111", Password = "******", Money = 100, Phone = "139139139", Address = "A4-409", UserName = "******", Status = 1
                    }, new User()
                    {
                        UserAccount = "11111111", Password = "******", Money = 100, Phone = "139139139", Address = "A4-409", UserName = "******", Status = 1
                    }, new User()
                    {
                        UserAccount = "11111111", Password = "******", Money = 100, Phone = "139139139", Address = "A4-409", UserName = "******", Status = 1
                    }, new User()
                    {
                        UserAccount = "11111111", Password = "******", Money = 100, Phone = "139139139", Address = "A4-409", UserName = "******", Status = 1
                    }, new User()
                    {
                        UserAccount = "11111111", Password = "******", Money = 100, Phone = "139139139", Address = "A4-409", UserName = "******", Status = 1
                    }, new User()
                    {
                        UserAccount = "11111111", Password = "******", Money = 100, Phone = "139139139", Address = "A4-409", UserName = "******", Status = 1
                    }, new User()
                    {
                        UserAccount = "11111111", Password = "******", Money = 100, Phone = "139139139", Address = "A4-409", UserName = "******", Status = 1
                    }, new User()
                    {
                        UserAccount = "11111111", Password = "******", Money = 100, Phone = "139139139", Address = "A4-409", UserName = "******", Status = 1
                    }, new User()
                    {
                        UserAccount = "11111111", Password = "******", Money = 100, Phone = "139139139", Address = "A4-409", UserName = "******", Status = 1
                    }, new User()
                    {
                        UserAccount = "11111111", Password = "******", Money = 100, Phone = "139139139", Address = "A4-409", UserName = "******", Status = 1
                    }, new User()
                    {
                        UserAccount = "11111111", Password = "******", Money = 100, Phone = "139139139", Address = "A4-409", UserName = "******", Status = 1
                    }, new User()
                    {
                        UserAccount = "11111111", Password = "******", Money = 100, Phone = "139139139", Address = "A4-409", UserName = "******", Status = 1
                    }, new User()
                    {
                        UserAccount = "11111111", Password = "******", Money = 100, Phone = "139139139", Address = "A4-409", UserName = "******", Status = 1
                    }, new User()
                    {
                        UserAccount = "11111111", Password = "******", Money = 100, Phone = "139139139", Address = "A4-409", UserName = "******", Status = 1
                    }, new User()
                    {
                        UserAccount = "11111111", Password = "******", Money = 100, Phone = "139139139", Address = "A4-409", UserName = "******", Status = 1
                    }, new User()
                    {
                        UserAccount = "11111111", Password = "******", Money = 100, Phone = "139139139", Address = "A4-409", UserName = "******", Status = 1
                    }, new User()
                    {
                        UserAccount = "11111111", Password = "******", Money = 100, Phone = "139139139", Address = "A4-409", UserName = "******", Status = 1
                    }, new User()
                    {
                        UserAccount = "11111111", Password = "******", Money = 100, Phone = "139139139", Address = "A4-409", UserName = "******", Status = 1
                    }, new User()
                    {
                        UserAccount = "11111111", Password = "******", Money = 100, Phone = "139139139", Address = "A4-409", UserName = "******", Status = 1
                    }, new User()
                    {
                        UserAccount = "11111111", Password = "******", Money = 100, Phone = "139139139", Address = "A4-409", UserName = "******", Status = 1
                    }, new User()
                    {
                        UserAccount = "11111111", Password = "******", Money = 100, Phone = "139139139", Address = "A4-409", UserName = "******", Status = 1
                    }, new User()
                    {
                        UserAccount = "11111111", Password = "******", Money = 100, Phone = "139139139", Address = "A4-409", UserName = "******", Status = 1
                    }, new User()
                    {
                        UserAccount = "11111111", Password = "******", Money = 100, Phone = "139139139", Address = "A4-409", UserName = "******", Status = 1
                    }, new User()
                    {
                        UserAccount = "11111111", Password = "******", Money = 100, Phone = "139139139", Address = "A4-409", UserName = "******", Status = 1
                    }, new User()
                    {
                        UserAccount = "11111111", Password = "******", Money = 100, Phone = "139139139", Address = "A4-409", UserName = "******", Status = 1
                    }, new User()
                    {
                        UserAccount = "11111111", Password = "******", Money = 100, Phone = "139139139", Address = "A4-409", UserName = "******", Status = 1
                    }, new User()
                    {
                        UserAccount = "11111111", Password = "******", Money = 100, Phone = "139139139", Address = "A4-409", UserName = "******", Status = 1
                    }, new User()
                    {
                        UserAccount = "11111111", Password = "******", Money = 100, Phone = "139139139", Address = "A4-409", UserName = "******", Status = 1
                    }, new User()
                    {
                        UserAccount = "11111111", Password = "******", Money = 100, Phone = "139139139", Address = "A4-409", UserName = "******", Status = 1
                    }, new User()
                    {
                        UserAccount = "11111111", Password = "******", Money = 100, Phone = "139139139", Address = "A4-409", UserName = "******", Status = 1
                    },
                        new User()
                    {
                        UserAccount = "11111111", Password = "******", Money = 100, Phone = "139139139", Address = "A4-409", UserName = "******", Status = 1
                    },
                        new User()
                    {
                        UserAccount = "2222222", Password = "******", Money = 100, Phone = "139139139", Address = "A4-410", UserName = "******", Status = 0
                    }
                        );
                    context.SaveChanges();
                }


                // Look for any SnackCategory.
                if (!context.SnackCategory.Any())
                {
                    context.SnackCategory.AddRange(


                        new SnackCategory()
                    {
                        CategoryNum = 1001, CategoryName = "零食", Description = "薯片,薯条,方便面等", Status = 1
                    },
                        new SnackCategory()
                    {
                        CategoryNum = 1002, CategoryName = "烧烤", Description = "微波炉现烤 热狗 骨肉相连等", Status = 0
                    }

                        );

                    context.SaveChanges();
                }


                // Look for any SnackInfo.
                if (!context.SnackInfo.Any())
                {
                    SnackInfo[] snackInfos = new SnackInfo[100];
                    for (int i = 0; i < 100; i++)
                    {
                        SnackInfo snackInfo = new SnackInfo()
                        {
                            ImgUrl     = "/images/book2.jpg",
                            Name       = $"精神beer{i}",
                            SnackNum   = Convert.ToInt32("1002" + i),
                            CategoryId = 1002,
                            DetailInfo = "精神麻辣烫",
                            Price      = 100 + i,
                            Status     = 1
                        };
                        snackInfos[i] = snackInfo;
                    }
                    context.SnackInfo.AddRange(snackInfos);

                    context.SaveChanges();
                }



                // Look for any SnackInfo.
                if (!context.Orders.Any())
                {
                    Order[] orders = new Order[100];
                    for (int i = 0; i < 100; i++)
                    {
                        Order temp_order = new Order()
                        {
                            OrderId     = DateTime.Now.ToString($"yyyyMMddhhmmss{i}"),
                            Discount    = 1,
                            OrderDetail = "beer*1 smock*3",
                            UserId      = 26,
                            TotalPrice  = 100 + i,
                            Status      = 0,
                            CreateTime  = DateTime.Now
                        };
                        orders[i] = temp_order;
                    }
                    context.Orders.AddRange(orders);

                    context.SaveChanges();
                }



                // Look for any Card.
                if (!context.prepaidCard.Any())
                {
                    prepaidCard[] cards = new prepaidCard[100];
                    for (int i = 0; i < 100; i++)
                    {
                        prepaidCard card = new prepaidCard()
                        {
                            CardCode    = $"ddaa{i}",
                            SecretKey   = $"adassad{i}",
                            CardStatus  = 0,
                            Price       = 50,
                            UserAccount = "666666666"
                        };
                        cards[i] = card;
                    }
                    context.prepaidCard.AddRange(cards);

                    context.SaveChanges();
                }
            }
        }