Ejemplo n.º 1
0
 public bool UserExists(string email)
 {
     using (var context = new TzedakahFundDataContext(_connectionString))
     {
         return(context.Users.Any(u => u.Email == email));
     }
 }
Ejemplo n.º 2
0
 public void EditCategory(string name, int id)
 {
     using (var context = new TzedakahFundDataContext(_connectionString))
     {
         context.ExecuteCommand("UPDATE Categories SET Name = {0} WHERE Id = {1}", name, id);
     }
 }
Ejemplo n.º 3
0
 public void DeleteCategory(int id)
 {
     using (var context = new TzedakahFundDataContext(_connectionString))
     {
         context.ExecuteCommand("DELETE Categories WHERE Id = {0}", id);
     }
 }
Ejemplo n.º 4
0
 public void RejectApplication(int id)
 {
     using (var context = new TzedakahFundDataContext(_connectionString))
     {
         context.ExecuteCommand("UPDATE Applications SET Status = 1 WHERE Id = {0}", id);
     }
 }
Ejemplo n.º 5
0
 //public IEnumerable<Application> GetApplications()
 //{
 //    using (var context = new TzedakahFundDataContext(_connectionString))
 //    {
 //        var loadOptions = new DataLoadOptions();
 //        loadOptions.LoadWith<Application>(a => a.User);
 //        loadOptions.LoadWith<Application>(a => a.Category);
 //        context.LoadOptions = loadOptions;
 //        return context.Applications.ToList();
 //    }
 //}
 public void AddApplication(Application a)
 {
     using (var context = new TzedakahFundDataContext(_connectionString))
     {
         a.Date = DateTime.Now;
         context.Applications.InsertOnSubmit(a);
         context.SubmitChanges();
     }
 }
Ejemplo n.º 6
0
 public IEnumerable <Category> GetCategories()
 {
     using (var context = new TzedakahFundDataContext(_connectionString))
     {
         var loadOptions = new DataLoadOptions();
         loadOptions.LoadWith <Category>(c => c.Applications);
         context.LoadOptions = loadOptions;
         return(context.Categories.ToList());
     }
 }
Ejemplo n.º 7
0
 public User GetUser(int id)
 {
     using (var context = new TzedakahFundDataContext(_connectionString))
     {
         var loadOptions = new DataLoadOptions();
         loadOptions.LoadWith <User>(u => u.Applications);
         loadOptions.LoadWith <Application>(a => a.Category);
         context.LoadOptions = loadOptions;
         return(context.Users.FirstOrDefault(u => u.Id == id));
     }
 }
Ejemplo n.º 8
0
 public void AddCategory(string name)
 {
     using (var context = new TzedakahFundDataContext(_connectionString))
     {
         Category c = new Category()
         {
             Name = name
         };
         context.Categories.InsertOnSubmit(c);
         context.SubmitChanges();
     }
 }
Ejemplo n.º 9
0
        public void AddUser(string firstName, string lastName, string email, string password)
        {
            string salt = GenerateSalt();
            string hash = HashPassword(password, salt);

            using (var context = new TzedakahFundDataContext(_connectionString))
            {
                User user = new User
                {
                    Email        = email,
                    FirstName    = firstName,
                    LastName     = lastName,
                    PasswordHash = hash,
                    PasswordSalt = salt
                };
                context.Users.InsertOnSubmit(user);
                context.SubmitChanges();
            }
        }
Ejemplo n.º 10
0
        public IEnumerable <Application> GetApplications(Status status)
        {
            using (var context = new TzedakahFundDataContext(_connectionString))
            {
                var loadOptions = new DataLoadOptions();
                loadOptions.LoadWith <Application>(a => a.User);
                loadOptions.LoadWith <Application>(a => a.Category);
                context.LoadOptions = loadOptions;

                if (status == Status.Approved)
                {
                    return(context.Applications.Where(a => a.Status == true).ToList());
                }
                else if (status == Status.Rejected)
                {
                    return(context.Applications.Where(a => a.Status == false).ToList());
                }
                else
                {
                    return(context.Applications.Where(a => a.Status == null).ToList());
                }
            }
        }