Esempio n. 1
0
        public bool UserInsert()
        {
            try
            {
                using (ITIndeedEntities dc = new ITIndeedEntities())
                {
                    if (dc.tblUsers.Where(u => u.UserName == this.UserName).FirstOrDefault() == null)
                    {
                        tblUser user = new tblUser();
                        user.Id       = Guid.NewGuid();
                        user.UserName = this.UserName;
                        user.Password = GetHash();

                        dc.tblUsers.Add(user);
                        dc.SaveChanges();

                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 2
0
        public void EmployerUpdate(Guid employerId)
        {
            try
            {
                using (ITIndeedEntities dc = new ITIndeedEntities())
                {
                    tblEmployer employer = dc.tblEmployers.Where(e => e.Id == employerId).FirstOrDefault();
                    tblUser     user     = dc.tblUsers.Where(u => u.Id == employer.UserId).FirstOrDefault();

                    if (employer != null && user != null)
                    {
                        employer.RepresentativeFirstName = (this.RepresentativeFirstName == null) ? employer.RepresentativeFirstName : this.RepresentativeFirstName;
                        employer.RepresentativeLastName  = (this.RepresentativeLastName == null) ? employer.RepresentativeLastName : this.RepresentativeLastName;
                        employer.Phone            = (this.Phone == null) ? employer.Phone: this.Phone;
                        employer.Email            = (this.Email == null) ? employer.Email : this.Email;
                        employer.Industry         = (this.Industry == null) ? employer.Industry : this.Industry;
                        employer.OrganizationName = (this.OrganizationName == null) ? employer.OrganizationName: this.OrganizationName;
                        user.UserName             = (this.UserName == null) ? user.UserName : this.UserName;
                        user.Password             = (this.Password == null) ? user.Password: this.Password;
                        employer.ProfilePicture   = (this.ProfilePicture == null) ? employer.ProfilePicture: this.ProfilePicture;

                        dc.SaveChanges();
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 3
0
        public bool AddUserInterestedInEvent(Guid userId)
        {
            try
            {
                using (ITIndeedEntities dc = new ITIndeedEntities())
                {
                    tblUserInterested eventInterested = dc.tblUserInteresteds.Where(e => (e.UserId == userId) && (e.EventId == this.Id)).FirstOrDefault(); // Check to see if user already joined event

                    if (eventInterested == null)
                    {
                        eventInterested         = new tblUserInterested();
                        eventInterested.Id      = Guid.NewGuid();
                        eventInterested.UserId  = userId;
                        eventInterested.EventId = this.Id;

                        dc.tblUserInteresteds.Add(eventInterested);
                        dc.SaveChanges();

                        return(true);
                    }
                    else
                    {
                        return(false); // User already interested in event.
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 4
0
        public void StudentUpdate()
        {
            try
            {
                using (ITIndeedEntities dc = new ITIndeedEntities())
                {
                    tblStudent student = dc.tblStudents.Where(s => s.Id == this.StudentID).FirstOrDefault();
                    tblUser    user    = dc.tblUsers.Where(u => u.Id == student.UserId).FirstOrDefault();

                    if (student != null && user != null)
                    {
                        student.StudentFirstName = (this.StudentFirstName == null) ? student.StudentFirstName: this.StudentFirstName;
                        student.StudentLastName  = (this.StudentLastName == null) ? student.StudentLastName: this.StudentLastName;
                        student.Phone            = this.Phone = (this.Phone == null) ? student.Phone : this.Phone;
                        student.Email            = (this.Email == null) ? student.Email : this.Email;
                        student.School           = (this.School == null) ? student.School : this.School;
                        student.Field            = (this.FieldOfStudy == null) ? student.Field : this.FieldOfStudy;
                        user.UserName            = (this.UserName == null) ? user.UserName : this.UserName;
                        user.Password            = (this.Password == null) ? user.Password : this.Password;
                        student.ProfilePicture   = (this.ProfilePicture == null) ? student.ProfilePicture : this.ProfilePicture;

                        dc.SaveChanges();
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 5
0
        public bool Insert()
        {
            try
            {
                using (ITIndeedEntities dc = new ITIndeedEntities())
                {
                    tblEvent tevent = new tblEvent();
                    tevent.Id        = Guid.NewGuid();
                    tevent.Name      = this.Name;
                    tevent.Type      = this.Type;
                    tevent.StartDate = Convert.ToDateTime(this.StartDate);
                    tevent.EndDate   = Convert.ToDateTime(this.EndDate);
                    //the error was the same thing as above all good now :)

                    dc.tblEvents.Add(tevent);
                    dc.SaveChanges();

                    return(true);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 6
0
        public bool AddUserToEvent(Guid userId)
        {
            try
            {
                using (ITIndeedEntities dc = new ITIndeedEntities())
                {
                    tblEventShowing eventShowing = dc.tblEventShowings.Where(e => (e.UserId == userId) && (e.EventId == this.Id)).FirstOrDefault();

                    if (eventShowing == null)
                    {
                        eventShowing         = new tblEventShowing();
                        eventShowing.Id      = Guid.NewGuid();
                        eventShowing.UserId  = userId;
                        eventShowing.EventId = this.Id;

                        dc.tblEventShowings.Add(eventShowing);
                        dc.SaveChanges();

                        return(true);
                    }
                    else
                    {
                        return(false); // User already attending event.
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 7
0
        public void UserDelete()
        {
            try
            {
                using (ITIndeedEntities dc = new ITIndeedEntities())
                {
                    tblUser user = dc.tblUsers.Where(u => u.Id == this.BaseUserID).FirstOrDefault();

                    if (user != null)
                    {
                        dc.tblUsers.Remove(user);

                        dc.SaveChanges();
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 8
0
        public void UserUpdate()
        {
            try
            {
                using (ITIndeedEntities dc = new ITIndeedEntities())
                {
                    tblUser user = dc.tblUsers.Where(u => u.Id == this.BaseUserID).FirstOrDefault();

                    if (user != null)
                    {
                        user.UserName = this.UserName;
                        user.Password = GetHash();

                        dc.SaveChanges();
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 9
0
        public void EmployerDelete()
        {
            try
            {
                using (ITIndeedEntities dc = new ITIndeedEntities())
                {
                    tblEmployer employer = dc.tblEmployers.Where(e => e.Id == this.EmployerId).FirstOrDefault();
                    tblUser     user     = dc.tblUsers.Where(u => u.Id == employer.UserId).FirstOrDefault();
                    if (employer != null & user != null)
                    {
                        dc.tblEmployers.Remove(employer);
                        dc.tblUsers.Remove(user);

                        dc.SaveChanges();
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 10
0
        public bool StudentInsert()
        {
            try
            {
                using (ITIndeedEntities dc = new ITIndeedEntities())
                {
                    tblUser user = new tblUser();

                    user.UserName = this.UserName;
                    user.Password = this.Password;
                    this.UserInsert();

                    tblUser userGetUserId = dc.tblUsers.Where(u => u.UserName == this.UserName).FirstOrDefault();
                    Guid    guidUserId    = userGetUserId.Id;

                    tblStudent student = new tblStudent();
                    student.Id = Guid.NewGuid();
                    student.StudentFirstName = this.StudentFirstName;
                    student.StudentLastName  = this.StudentLastName;
                    student.Phone            = this.Phone;
                    student.Email            = this.Email;
                    student.School           = this.School;
                    student.Field            = this.FieldOfStudy;
                    student.UserId           = guidUserId;
                    student.ProfilePicture   = this.ProfilePicture;

                    dc.tblStudents.Add(student);

                    dc.SaveChanges();

                    return(true);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 11
0
        public void StudentDelete()
        {
            try
            {
                using (ITIndeedEntities dc = new ITIndeedEntities())
                {
                    tblStudent student = dc.tblStudents.Where(s => s.Id == this.StudentID).FirstOrDefault();
                    tblUser    user    = dc.tblUsers.Where(u => u.Id == student.UserId).FirstOrDefault();

                    if (student != null)
                    {
                        dc.tblStudents.Remove(student);
                        dc.tblUsers.Remove(user);

                        dc.SaveChanges();
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 12
0
        public bool EmployerInsert()
        {
            try
            {
                using (ITIndeedEntities dc = new ITIndeedEntities())
                {
                    tblUser user = new tblUser();

                    user.UserName = this.UserName;
                    user.Password = this.Password;
                    this.UserInsert();

                    tblUser userGetUserId = dc.tblUsers.Where(u => u.UserName == this.UserName).FirstOrDefault();
                    Guid    guidUserId    = userGetUserId.Id;

                    tblEmployer employer = new tblEmployer();
                    employer.Id = Guid.NewGuid();
                    employer.RepresentativeFirstName = this.RepresentativeFirstName;
                    employer.RepresentativeLastName  = this.RepresentativeLastName;
                    employer.Phone            = this.Phone;
                    employer.Email            = this.Email;
                    employer.OrganizationName = this.OrganizationName;
                    employer.Industry         = this.Industry;
                    employer.UserId           = guidUserId;
                    employer.ProfilePicture   = this.ProfilePicture;

                    dc.tblEmployers.Add(employer);
                    dc.SaveChanges();

                    return(true);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 13
0
        public void Delete()
        {
            try
            {
                using (ITIndeedEntities dc = new ITIndeedEntities())
                {
                    tblEvent tevent = dc.tblEvents.Where(e => e.Id == this.Id).FirstOrDefault();

                    if (tevent != null)
                    {
                        var eventShowings = dc.tblEventShowings.Where(e => e.EventId == this.Id);

                        dc.tblEventShowings.RemoveRange(eventShowings);
                        dc.tblEvents.Remove(tevent);

                        dc.SaveChanges();
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 14
0
        public void Update()
        {
            try
            {
                using (ITIndeedEntities dc = new ITIndeedEntities())
                {
                    tblEvent tevent = dc.tblEvents.Where(e => e.Id == this.Id).FirstOrDefault();

                    if (tevent != null)
                    {
                        tevent.Name      = this.Name;
                        tevent.Type      = this.Type;
                        tevent.StartDate = this.StartDate;
                        tevent.EndDate   = this.EndDate;

                        dc.SaveChanges();
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }