public int InsertUsers(string Firstname, string LastName, string EmailAddress, string PasswordHash, int UserType, int Gender, int Department, int _StatusId)

        {
            using (var _ObjDBContext = new BusinessUnitsDBContext())
            {
                ///try
                // {
                var _ObjRegisterusers = new RegisteredUser

                {
                    //UserId = UserId,
                    FirstName    = Firstname,
                    Lastname     = LastName,
                    EmailAddress = EmailAddress,
                    Passwordhash = PasswordHash,
                    UserTypeId   = UserType,
                    GenderId     = Gender,
                    DepartmentId = Department,
                    StatusId     = _StatusId
                };
                _ObjDBContext.RegisterUser.Add(_ObjRegisterusers);


                _ObjDBContext.SaveChanges();
                Console.WriteLine("Sucessful");
                Console.ReadKey();
                return(_ObjRegisterusers.UserId);
            }
        }
Beispiel #2
0
 internal void UpdateUserAlternative(RegisteredUser user)
 {
     using (var _ObjDBContext = new BusinessUnitsDBContext())
     {
         _ObjDBContext.RegisterUser.Attach(user);
         _ObjDBContext.SaveChanges();
     }
 }
Beispiel #3
0
        public RegisteredUser FindUserById(int UserId)
        {
            using (var _ObjDBContext = new BusinessUnitsDBContext())
            {
                var _ObjRegisterusers = _ObjDBContext.RegisterUser.FirstOrDefault(user => user.UserId == UserId);

                return(_ObjRegisterusers);
            }
        }
Beispiel #4
0
        public void UpdateUser(int UserId, string Firstname, string LastName, string EmailAddress, string PasswordHash, int UserType, int Gender, int Department, int _StatusId)

        {
            using (var _ObjDBContext = new BusinessUnitsDBContext())
            {
                //select record using UserID



                var _ObjRegisterusers = _ObjDBContext.RegisterUser.FirstOrDefault(user => user.UserId == UserId);

                //if != null then  update
                if (_ObjRegisterusers != null)
                {
                    _ObjRegisterusers.FirstName    = Firstname;
                    _ObjRegisterusers.Lastname     = LastName;
                    _ObjRegisterusers.EmailAddress = EmailAddress;
                    _ObjRegisterusers.Passwordhash = PasswordHash;
                    _ObjRegisterusers.UserTypeId   = UserType;
                    _ObjRegisterusers.GenderId     = Gender;
                    _ObjRegisterusers.DepartmentId = Department;
                    _ObjRegisterusers.StatusId     = _StatusId;
                }
                else
                {
                    //do soomething else
                }


                _ObjDBContext.RegisterUser.Attach(_ObjRegisterusers);
                _ObjDBContext.SaveChanges();

                Console.WriteLine("Sucessful");
                Console.ReadKey();

                //   }

                //catch (Exception)
                //{

                //    Console.WriteLine("Could not insert Department");
                //    Console.ReadKey();
                //}
            }
        }
Beispiel #5
0
        public void Join()
        {
            BusinessUnitsDBContext Context = new BusinessUnitsDBContext();
            var query = from ReadUsers in Context.RegisterUser
                        join gender in Context.Gender
                        on ReadUsers.GenderId equals
                        gender.GenderId
                        join approvl_status in Context.ApprovalStatuses
                        on ReadUsers.StatusId equals
                        approvl_status.StatusId
                        where approvl_status.IsApproved == false
                        //from
                        select new { ReadUsers.FirstName, ReadUsers.Lastname, approvl_status.IsApproved, gender.Sex };

            //Displaying the resualts
            foreach (var unapproved in query)
            {
                Console.WriteLine("Details {0}, {1}, {2}, {3} ", unapproved.FirstName, unapproved.Lastname, unapproved.IsApproved, unapproved.Sex);
            }
        }
Beispiel #6
0
        public void DeleteUser(int UserId)

        {
            using (var _ObjDBContext = new BusinessUnitsDBContext())
            {
                //select record using UserID



                var _ObjRegisterusers = _ObjDBContext.RegisterUser.FirstOrDefault(user => user.UserId == UserId);

                //if != null then  delete
                if (_ObjRegisterusers != null)

                {
                    _ObjDBContext.RegisterUser.Remove(_ObjRegisterusers);
                }
                _ObjDBContext.SaveChanges();

                Console.WriteLine("User Deleted ");
                Console.ReadKey();
            }
        }
Beispiel #7
0
        public void AddressAdd(int UserId, int ProvinceId, int CityId, int SurburbId, int RegionId, string StreetName, int Unit)

        {
            using (var _ObjDBContext = new BusinessUnitsDBContext())
            {
                //var _user = _ObjDBContext.RegisterUser.Find(UserId);
                var _ObjAddressAdd = new PhysicalAddress
                {
                    UserId     = UserId,
                    ProvinceId = ProvinceId,
                    CityId     = CityId,
                    SuburbId   = SurburbId,
                    RegionId   = RegionId,
                    StreetName = StreetName,
                    Unit       = Unit
                };

                _ObjDBContext.PhysicalAddress.Add(_ObjAddressAdd);
                _ObjDBContext.SaveChanges();

                Console.WriteLine("Sucessful");
                Console.ReadKey();
            }
        }