Exemplo n.º 1
0
 public void AddFile(Image image)
 {
     using (var dc = new CheckingContext(_connectionString))
     {
         dc.Images.Add(image);
         dc.SaveChanges();
     }
 }
Exemplo n.º 2
0
 public Order UpdateOrder(Order order, Questionnaire q)
 {
     using (CheckingContext db = new CheckingContext(_connectionString))
     {
         Order o = db.Orders.Find(order.OrderID);
         o.Questionnaire = q;
         db.SaveChanges();
     }
     return(order);
 }
Exemplo n.º 3
0
        public int CreateOrder(Order o)
        {
            using (CheckingContext db = new CheckingContext(_connectionString))
            {
                db.Orders.Add(o);
                db.SaveChanges();
            }

            return(o.OrderID);
        }
Exemplo n.º 4
0
        public Order GetOrder(int orderId)
        {
            Order o = null;

            using (CheckingContext db = new CheckingContext(_connectionString))
            {
                o = db.Orders.Find(orderId);
                var email = o.User.UserName;
            }
            return(o);
        }
Exemplo n.º 5
0
 public bool HasPendingOrder(int userID)
 {
     using (var dc = new CheckingContext(_connectionString))
     {
         var user = dc.Users.Find(userID);
         if (user == null)
         {
             return(false);
         }
         return(user.Orders.Count == 0 ? false: user.Orders.Last().OrderStatus != OrderStatus.Paid);
     }
 }
Exemplo n.º 6
0
 public User GetUser(string username, string password)
 {
     using (var dc = new CheckingContext(_connectionString))
     {
         var user = dc.Users.FirstOrDefault(a => a.UserName == username);
         if (user == null)
         {
             return(null);
         }
         bool success = PasswordHelper.PasswordMatch(password, user.PasswordHash, user.Salt);
         return(success ? user : null);
     }
 }
Exemplo n.º 7
0
        public void AddUser(string username, string password)
        {
            User   user         = new User();
            string salt         = PasswordHelper.GenerateRandomSalt();
            string passwordHash = PasswordHelper.HashPassword(password, salt);

            user.PasswordHash = passwordHash;
            user.Salt         = salt;
            user.UserName     = username;
            user.Role         = Role.Admin;
            using (var dc = new CheckingContext(_connectionString))
            {
                dc.Users.Add(user);
                dc.SaveChanges();
            }
        }
Exemplo n.º 8
0
        public List <string> GetImagePaths(int orderId)
        {
            List <string> paths = new List <string>();

            using (CheckingContext db = new CheckingContext(_connectionString))
            {
                Order order = db.Orders.Find(orderId);
                foreach (var i in order.Images)
                {
                    string s = Path.GetFullPath(i.FileName);
                    paths.Add(s);
                    // FileStream stream = new FileStream(s, FileMode.Open);
                }
            }
            return(paths);
        }