Esempio n. 1
0
 public IEnumerable <string> GetIncomeCategories()
 {
     using (var context = new ExpenseEntities())
     {
         var result = context.Incomecategory.Select(x => x.CategoryName).ToList();
         return(result);
     }
 }
Esempio n. 2
0
 public bool UserExists(string name)
 {
     using (var context = new ExpenseEntities())
     {
         var result = context.Users.Any(x => x.Name == name);
         return(result);
     }
 }
Esempio n. 3
0
 public int GetUserID(string name)
 {
     using (var context = new ExpenseEntities())
     {
         var result = context.Users.Where(x => x.Name == name).Select(x => x.Id).FirstOrDefault();
         return(Convert.ToInt32(result));
     }
 }
Esempio n. 4
0
 public bool ValidateUser(string name, string password)
 {
     using (var context = new ExpenseEntities())
     {
         var result = context.Users.Any(x => x.Name == name && x.Password == password);
         return(result);
     }
 }
Esempio n. 5
0
 public List <ExpenseBO> GetAllExpenses()
 {
     using (var context = new ExpenseEntities())
     {
         var result = context.Expenses.Select(x => new ExpenseBO {
             Category = x.Category.CategoryName, Desc = x.Description, Date = x.Date, Price = x.Price
         }).ToList();
         return(result);
     }
 }
Esempio n. 6
0
 public void CreateNewCategory(string name)
 {
     using (var context = new ExpenseEntities())
     {
         ExpenseCategory category = new ExpenseCategory()
         {
             CategoryName = name
         };
         context.ExpenseCategory.Add(category);
         context.SaveChanges();
     }
 }
Esempio n. 7
0
 public void CreateNewUser(string name, string password)
 {
     using (var context = new ExpenseEntities())
     {
         Users user = new Users()
         {
             Name = name, Password = password
         };
         context.Users.Add(user);
         context.SaveChanges();
     }
 }
Esempio n. 8
0
 public List <ExpenseBO> SumMonthlyExpanses()
 {
     using (var context = new ExpenseEntities())
     {
         var result = context.Expenses
                      .GroupBy(g => new { g.Date.Month, g.Date.Year })
                      .Select(g => new ExpenseBO {
             Month = g.Key.Month, Price = g.Sum(x => x.Price)
         }).ToList();
         return(result);
     }
 }
Esempio n. 9
0
 public void CreateNewExpense(string description, DateTime date, string category, decimal price)
 {
     using (var context = new ExpenseEntities())
     {
         ExpenseCategory cat     = context.ExpenseCategory.Where(x => x.CategoryName == category).FirstOrDefault();
         Expenses        expense = new Expenses()
         {
             Description = description, Date = date, Price = price, Category = cat, Users_ID = Global.UserID
         };
         context.Expenses.Add(expense);
         context.SaveChanges();
     }
 }