public int EmailCounter(string email)
 {
     using (SQLiteDBContext dbConnection = this.OpenConnection())
     {
         var emailCount = dbConnection.User.Where(u => u.Email == email).Count();
         return(emailCount);
     }
 }
 public int GetUserIdByLogin(string username, string password)
 {
     using (SQLiteDBContext dbConnection = this.OpenConnection())
     {
         var user = dbConnection.User.Where(u => u.Username == username && u.Password == password).ToList().LastOrDefault();
         return(user?.Id ?? 0);
     }
 }
 public int UsernameCounter(string username)
 {
     using (SQLiteDBContext dbConnection = this.OpenConnection())
     {
         var usernameCount = dbConnection.User.Where(u => u.Username == username).Count();
         return(usernameCount);
     }
 }
 public IEnumerable <UserModel> GetAll()
 {
     using (SQLiteDBContext dbConnection = this.OpenConnection())
     {
         var users = dbConnection.User.ToList();
         return(users.Select(u => new UserModel(u)).ToList());
     }
 }
Пример #5
0
 public int PhoneCounter(string phone)
 {
     using (SQLiteDBContext dbConnection = this.OpenConnection())
     {
         var phoneCount = dbConnection.Customer.Where(c => c.Phone == Convert.ToInt32(phone)).Count();
         return(phoneCount);
     }
 }
 public void Insert(User user)
 {
     using (SQLiteDBContext dbConnection = this.OpenConnection())
     {
         dbConnection.User.Add(user);
         dbConnection.SaveChanges();
     }
 }
Пример #7
0
 public ActivityModel GetLastActivity(int id)
 {
     using (SQLiteDBContext dbConnection = this.OpenConnection())
     {
         var lastActivity = dbConnection.Activity.Where(a => a.CustomerId == id).ToList();
         return(lastActivity.LastOrDefault().ToModel());
     }
 }
Пример #8
0
 public IEnumerable <ActivityModel> GetActivitiesByCustomerId(int customerId)
 {
     using (SQLiteDBContext dbConnection = this.OpenConnection())
     {
         var activities = dbConnection.Activity.Where(a => a.CustomerId == customerId).ToList();
         return(activities.Select(a => new ActivityModel(a)).ToList());
     }
 }
Пример #9
0
 public void InsertActivity(Activity activity)
 {
     using (SQLiteDBContext dbConnection = this.OpenConnection())
     {
         dbConnection.Activity.Add(activity);
         dbConnection.SaveChanges();
     }
 }
Пример #10
0
 public void Insert(Customer customer)
 {
     using (SQLiteDBContext dbConnection = this.OpenConnection())
     {
         dbConnection.Customer.Add(customer);
         dbConnection.SaveChanges();
     }
 }
Пример #11
0
 public UserModel GetById(int id)
 {
     using (SQLiteDBContext dbConnection = this.OpenConnection())
     {
         var user = dbConnection.User.Where(u => u.Id == id).FirstOrDefault();
         return(user == null ? null : new UserModel(user));
     }
 }
 public IEnumerable <UserModel> GetUsersByPage(int count, int pageNo)
 {
     using (SQLiteDBContext dbConnection = this.OpenConnection())
     {
         var skipCount = count * (pageNo - 1);
         var users     = dbConnection.User.Skip(skipCount).Take(count).ToList();
         return(users.Select(u => new UserModel(u)).ToList());
     }
 }
Пример #13
0
 public IEnumerable <CustomerModel> GetCustomersByPage(int count, int pageNo)
 {
     using (SQLiteDBContext dbConnection = this.OpenConnection())
     {
         var skipCount = count * (pageNo - 1);
         var customers = dbConnection.Customer.Skip(skipCount).Take(count).ToList();
         return(customers.Select(a => new CustomerModel(a)).ToList());
     }
 }
Пример #14
0
 public ActivityModel GetActivityById(int id)
 {
     using (SQLiteDBContext dbConnection = this.OpenConnection())
     {
         //var user = dbConnection.Users.Where(u => u.Id == id).FirstOrDefault();
         var activity = dbConnection.Activity.Find(id);
         return(new ActivityModel(activity));
     }
 }
Пример #15
0
 public CustomerModel GetById(int id)
 {
     using (SQLiteDBContext dbConnection = this.OpenConnection())
     {
         //var user = dbConnection.Users.Where(u => u.Id == id).FirstOrDefault();
         var customer = dbConnection.Customer.Find(id);
         return(new CustomerModel(customer));
     }
 }
 public void Log(LogType logType, string message)
 {
     using (SQLiteDBContext dbConnection = this.OpenConnection())
     {
         Log newLog = new Log();
         newLog.Type      = logType;
         newLog.Message   = message;
         newLog.Timestamp = DateTime.UtcNow.Ticks;
         dbConnection.Log.Add(newLog);
         dbConnection.SaveChanges();
     }
 }