示例#1
0
        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);
            }
        }
示例#2
0
 internal void UpdateUserAlternative(RegisteredUser user)
 {
     using (var _ObjDBContext = new BusinessUnitsDBContext())
     {
         _ObjDBContext.RegisterUser.Attach(user);
         _ObjDBContext.SaveChanges();
     }
 }
示例#3
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();
                //}
            }
        }
示例#4
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();
            }
        }
示例#5
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();
            }
        }