public User getUser(int id) { MoneyManagementEntities2 db = new MoneyManagementEntities2(); User loggedInUser = db.Users.Find(id); return(loggedInUser); }
public void Delete(int id) { MoneyManagementEntities2 db = new MoneyManagementEntities2(); User u = db.Users.Find(id); db.Users.Add(u); db.SaveChanges(); }
public List<Expens> getAllExpeces() { MoneyManagementEntities2 db = new MoneyManagementEntities2(); List<Expens> list = new List<Expens>(); list = db.Expenses.ToList(); return list; }
public void unSlect(int Bid, int uid) { MoneyManagementEntities2 db = new MoneyManagementEntities2(); Budget b = db.Budgets.Find(Bid); b.isCurrent = false; db.SaveChanges(); }
public List <Expens> getAllExpeces() { MoneyManagementEntities2 db = new MoneyManagementEntities2(); List <Expens> list = new List <Expens>(); list = db.Expenses.ToList(); return(list); }
public void AddBudgetFromFile(String path, int UserId) { FileStream fs = new FileStream(path, FileMode.Open); StreamReader sr = new StreamReader(fs); String name = sr.ReadLine(); String StartDate = sr.ReadLine(); String endDate = sr.ReadLine(); String Income = sr.ReadLine(); String ExpCatagories = sr.ReadLine(); String ExpCatagoriesRanges = sr.ReadLine(); sr.Close(); fs.Close(); Budget b = new Budget(); b.Name = name; b.UID = UserId; b.StartDate = DateTime.ParseExact(StartDate, "dd/MM/yyyy", null); b.EndDate = DateTime.ParseExact(endDate, "dd/MM/yyyy", null); b.Income = Int32.Parse(Income); b.isCurrent = true; MoneyManagementEntities2 db = new MoneyManagementEntities2(); Budget AlreadySelectedBudget = null; foreach (Budget curr in db.Budgets) { if (curr.isCurrent == true) { AlreadySelectedBudget = curr; } } if (AlreadySelectedBudget != null) { AlreadySelectedBudget.isCurrent = false; db.SaveChanges(); } db.Budgets.Add(b); db.SaveChanges(); String [] catagories = ExpCatagories.Split(','); String[] catagoriesRanges = ExpCatagoriesRanges.Split(','); ExpenseCatagory Bcatagory = new ExpenseCatagory(); for (int i = 0; i < catagories.Length; i++) { Bcatagory.BID = b.BID; Bcatagory.CatName = catagories[i]; Bcatagory.CatRange = Int32.Parse(catagoriesRanges[i]); Bcatagory.Rangepercentage = ((Bcatagory.CatRange / b.Income) * 100); Bcatagory.ExpensesSum = 0; db.ExpenseCatagories.Add(Bcatagory); db.SaveChanges(); } }
public bool checkAvailability(String email) { MoneyManagementEntities2 db = new MoneyManagementEntities2(); foreach (User u in db.Users) { if (u.Email == email) return true; } return false; }
public List<Budget> getAllBudgets(int id) { List<Budget> budgets = new List<Budget>(); MoneyManagementEntities2 db = new MoneyManagementEntities2(); User LoggedInUser = db.Users.Find(id); foreach (Budget b in LoggedInUser.Budgets) { budgets.Add(b); } return budgets; }
public List <Budget> getAllBudgets(int id) { List <Budget> budgets = new List <Budget>(); MoneyManagementEntities2 db = new MoneyManagementEntities2(); User LoggedInUser = db.Users.Find(id); foreach (Budget b in LoggedInUser.Budgets) { budgets.Add(b); } return(budgets); }
public List<ExpenseCatagory> getAllExpCatagoriesOfSelectedBudget(int UserID) { MoneyManagementEntities2 db = new MoneyManagementEntities2(); User u = db.Users.Find(UserID); List<ExpenseCatagory> list = new List<ExpenseCatagory>(); foreach(Budget b in u.Budgets) { if (b.isCurrent == true) list = b.ExpenseCatagories.ToList(); } return list; }
public void SaveEditProfile(User u,int loggedInUserId) { MoneyManagementEntities2 db = new MoneyManagementEntities2(); User loggedInUser = db.Users.Find(loggedInUserId); if (u.Name != null) loggedInUser.Name = u.Name; if (u.Email != null) loggedInUser.Email = u.Email; if (u.password != null) loggedInUser.password = u.password; db.SaveChanges(); }
public bool checkAvailability(String email) { MoneyManagementEntities2 db = new MoneyManagementEntities2(); foreach (User u in db.Users) { if (u.Email == email) { return(true); } } return(false); }
public void AddBudgetFromFile(String path,int UserId) { FileStream fs = new FileStream(path, FileMode.Open); StreamReader sr = new StreamReader(fs); String name = sr.ReadLine(); String StartDate = sr.ReadLine(); String endDate = sr.ReadLine(); String Income = sr.ReadLine(); String ExpCatagories = sr.ReadLine(); String ExpCatagoriesRanges = sr.ReadLine(); sr.Close(); fs.Close(); Budget b = new Budget(); b.Name = name; b.UID = UserId; b.StartDate = DateTime.ParseExact(StartDate, "dd/MM/yyyy", null); b.EndDate = DateTime.ParseExact(endDate, "dd/MM/yyyy", null); b.Income = Int32.Parse(Income); b.isCurrent = true; MoneyManagementEntities2 db = new MoneyManagementEntities2(); Budget AlreadySelectedBudget = null; foreach (Budget curr in db.Budgets) { if (curr.isCurrent == true) AlreadySelectedBudget = curr; } if (AlreadySelectedBudget != null) { AlreadySelectedBudget.isCurrent = false; db.SaveChanges(); } db.Budgets.Add(b); db.SaveChanges(); String [] catagories = ExpCatagories.Split(','); String[] catagoriesRanges = ExpCatagoriesRanges.Split(','); ExpenseCatagory Bcatagory = new ExpenseCatagory(); for (int i = 0; i < catagories.Length; i++ ) { Bcatagory.BID = b.BID; Bcatagory.CatName = catagories[i]; Bcatagory.CatRange = Int32.Parse(catagoriesRanges[i]); Bcatagory.Rangepercentage = ( (Bcatagory.CatRange / b.Income) * 100 ); Bcatagory.ExpensesSum = 0; db.ExpenseCatagories.Add(Bcatagory); db.SaveChanges(); } }
bool IsAlreadyExist(String Email) { MoneyManagementEntities2 db = new MoneyManagementEntities2(); foreach (User user in db.Users) { if (user.Email == Email) { //User already exists... we Don't have to add it again return(true); } } return(false); }
public List <Expens> getAllExpecesOfSelectedBudget(int userID) { MoneyManagementEntities2 db = new MoneyManagementEntities2(); User u = db.Users.Find(userID); List <Expens> list = new List <Expens>(); foreach (Budget b in u.Budgets) { if (b.isCurrent == true) { list = b.Expenses.ToList(); } } return(list); }
public void DeleteBudget(int id) { MoneyManagementEntities2 db = new MoneyManagementEntities2(); Budget b = db.Budgets.Find(id); List<ExpenseCatagory> catagories = new List<ExpenseCatagory>(); foreach (ExpenseCatagory c in b.ExpenseCatagories) { catagories.Add(c); } foreach (ExpenseCatagory c in catagories) { db.ExpenseCatagories.Remove(c); } db.Budgets.Remove(b); db.SaveChanges(); }
public void DeleteBudget(int id) { MoneyManagementEntities2 db = new MoneyManagementEntities2(); Budget b = db.Budgets.Find(id); List <ExpenseCatagory> catagories = new List <ExpenseCatagory>(); foreach (ExpenseCatagory c in b.ExpenseCatagories) { catagories.Add(c); } foreach (ExpenseCatagory c in catagories) { db.ExpenseCatagories.Remove(c); } db.Budgets.Remove(b); db.SaveChanges(); }
public bool SaveUser(User u) { MoneyManagementEntities2 db = new MoneyManagementEntities2(); User Authentic_user = null; bool isExist = IsAlreadyExist(u.Email); //This means user not already exist in database if (isExist == false) { Authentic_user = u; } if (Authentic_user != null && u != null) { db.Users.Add(u); db.SaveChanges(); return true; } return false; }
public void SaveEditProfile(User u, int loggedInUserId) { MoneyManagementEntities2 db = new MoneyManagementEntities2(); User loggedInUser = db.Users.Find(loggedInUserId); if (u.Name != null) { loggedInUser.Name = u.Name; } if (u.Email != null) { loggedInUser.Email = u.Email; } if (u.password != null) { loggedInUser.password = u.password; } db.SaveChanges(); }
public bool SaveUser(User u) { MoneyManagementEntities2 db = new MoneyManagementEntities2(); User Authentic_user = null; bool isExist = IsAlreadyExist(u.Email); //This means user not already exist in database if (isExist == false) { Authentic_user = u; } if (Authentic_user != null && u != null) { db.Users.Add(u); db.SaveChanges(); return(true); } return(false); }
public List<SearchExpense> SearchExpenses(String SearchText) { MoneyManagementEntities2 db = new MoneyManagementEntities2(); List<SearchExpense> SearchedExpenses = new List<SearchExpense>(); List<Expens> all = db.Expenses.ToList(); for (int i = 0; i < all.Count; i++ ) { Expens e = all[i]; if (e.Description.Contains(SearchText)) { SearchExpense ex = new SearchExpense(); ex.Amount = e.Amount; ex.Description = e.Description; ex.BudgetName = e.Budget.Name; SearchedExpenses.Add(ex); //SearchedExpenses.Add(e); } } return SearchedExpenses; }
public int Authenticate(User u) { MoneyManagementEntities2 db = new MoneyManagementEntities2(); User Authentic_user = null; foreach (User user in db.Users) { if ((user.Email == u.Email) && (user.password == u.password)) { Authentic_user = user; } } if (Authentic_user == null) { return -1; } else { return Authentic_user.UID; } }
public List <SearchExpense> SearchExpenses(String SearchText) { MoneyManagementEntities2 db = new MoneyManagementEntities2(); List <SearchExpense> SearchedExpenses = new List <SearchExpense>(); List <Expens> all = db.Expenses.ToList(); for (int i = 0; i < all.Count; i++) { Expens e = all[i]; if (e.Description.Contains(SearchText)) { SearchExpense ex = new SearchExpense(); ex.Amount = e.Amount; ex.Description = e.Description; ex.BudgetName = e.Budget.Name; SearchedExpenses.Add(ex); //SearchedExpenses.Add(e); } } return(SearchedExpenses); }
public int Authenticate(User u) { MoneyManagementEntities2 db = new MoneyManagementEntities2(); User Authentic_user = null; foreach (User user in db.Users) { if ((user.Email == u.Email) && (user.password == u.password)) { Authentic_user = user; } } if (Authentic_user == null) { return(-1); } else { return(Authentic_user.UID); } }
public void Slect(int Bid, int uid) { MoneyManagementEntities2 db = new MoneyManagementEntities2(); Budget AlreadySelectedBudget = null; User u = db.Users.Find(uid); foreach (Budget curr in u.Budgets) { if (curr.isCurrent == true) { AlreadySelectedBudget = curr; } } if (AlreadySelectedBudget != null) { AlreadySelectedBudget.isCurrent = false; db.SaveChanges(); } Budget B = db.Budgets.Find(Bid); B.isCurrent = true; db.SaveChanges(); }
public void SaveBudget(Budget b, String catagories, String ranges) { MoneyManagementEntities2 db = new MoneyManagementEntities2(); db.Budgets.Add(b); db.SaveChanges(); String[] catagoriesList = catagories.Split(','); String[] rangesList = ranges.Split(','); Budget currBudget = db.Budgets.Find(b.BID); for (int i = 0; i < catagoriesList.Length; i++) { ExpenseCatagory cat = new ExpenseCatagory(); cat.BID = b.BID; cat.CatName = catagoriesList[i]; cat.CatRange = Int32.Parse(rangesList[i]); cat.Rangepercentage = ((cat.CatRange / currBudget.Income) * 100); cat.ExpensesSum = 0; db.ExpenseCatagories.Add(cat); db.SaveChanges(); } }
public void saveExpense(Expens exp,String catName,int UserID) { MoneyManagementEntities2 db = new MoneyManagementEntities2(); User u = db.Users.Find(UserID); Budget SelectedBudget = new Budget(); foreach (Budget b in u.Budgets) { if (b.isCurrent == true) { exp.BID = b.BID; SelectedBudget = b; } } foreach(ExpenseCatagory expCat in SelectedBudget.ExpenseCatagories) { if (expCat.CatName == catName) { exp.ExpCat = expCat.ExpCatId; } } db.Expenses.Add(exp); db.SaveChanges(); }
public void saveExpense(Expens exp, String catName, int UserID) { MoneyManagementEntities2 db = new MoneyManagementEntities2(); User u = db.Users.Find(UserID); Budget SelectedBudget = new Budget(); foreach (Budget b in u.Budgets) { if (b.isCurrent == true) { exp.BID = b.BID; SelectedBudget = b; } } foreach (ExpenseCatagory expCat in SelectedBudget.ExpenseCatagories) { if (expCat.CatName == catName) { exp.ExpCat = expCat.ExpCatId; } } db.Expenses.Add(exp); db.SaveChanges(); }
public void Slect(int Bid,int uid) { MoneyManagementEntities2 db = new MoneyManagementEntities2(); Budget AlreadySelectedBudget = null; User u = db.Users.Find(uid); foreach (Budget curr in u.Budgets) { if (curr.isCurrent == true) AlreadySelectedBudget = curr; } if (AlreadySelectedBudget != null) { AlreadySelectedBudget.isCurrent = false; db.SaveChanges(); } Budget B = db.Budgets.Find(Bid); B.isCurrent = true; db.SaveChanges(); }
public User getUser(int id) { MoneyManagementEntities2 db = new MoneyManagementEntities2(); User loggedInUser = db.Users.Find(id); return loggedInUser; }
public void unSlect(int Bid,int uid) { MoneyManagementEntities2 db = new MoneyManagementEntities2(); Budget b = db.Budgets.Find(Bid); b.isCurrent = false; db.SaveChanges(); }
bool IsAlreadyExist(String Email) { MoneyManagementEntities2 db = new MoneyManagementEntities2(); foreach (User user in db.Users) { if (user.Email == Email) { //User already exists... we Don't have to add it again return true; } } return false; }