Example #1
0
        public Boolean CreateUser(ref UserBDO userBDO, ref string message)
        {
            message = "User Added Successfully";
            bool ret = true;

             UserType ut = new UserType()
                {
                    UserType1 = userBDO.UserType.UsersType,
                    UserTypeCode = userBDO.UserType.UserTypeCode
                };
             User u = new User()
                {

                    UserName = userBDO.UserName,
                    Password = userBDO.Password,
                    LastName = userBDO.LastName,
                    FirstName = userBDO.FirstName,
                    MiddleName = userBDO.MiddleName,
                    UserTypeCode = userBDO.UserType.UserTypeCode,
                    UserType = ut
                };

              using (var DCEnt = new DCFIEntities()) {
                    DCEnt.Users.Attach(u);
                    DCEnt.Entry(u).State = System.Data.Entity.EntityState.Added;
                    int num = DCEnt.SaveChanges();
                    userBDO.UserId = u.UserId;

                    if (num != 1) {
                        ret = false;
                        message = "Adding of User failed";
                    }
            }
            return ret;
        }
Example #2
0
        public Boolean CreateUser(ref UserBDO userBDO, ref string message)
        {
            message = "User Added Successfully";
            bool ret = true;

             UserType ut = new UserType()
                {
                    UserType1 = userBDO.UserType.UsersType,
                    UserTypeCode = userBDO.UserType.UserTypeCode
                };
             User u = new User()
                {

                    UserName = userBDO.UserName,
                    Password = userBDO.Password,
                    LastName = userBDO.LastName,
                    FirstName = userBDO.FirstName,
                    MiddleName = userBDO.MiddleName,
                    UserTypeCode = userBDO.UserType.UserTypeCode,
                    UserType = ut
                };
            try {
              using (var DCEnt = new DCFIEntities()) {
                    DCEnt.Users.Attach(u);
                    DCEnt.Entry(u).State = System.Data.Entity.EntityState.Added;
                    int num = DCEnt.SaveChanges();
                    userBDO.UserId = u.UserId;

                    if (num != 1) {
                        ret = false;
                        message = "Adding of User failed";
                    }
            }
            }
            catch (DbEntityValidationException dbEx)
            {
                foreach (var validationErrors in dbEx.EntityValidationErrors)
                {
                    foreach (var validationError in validationErrors.ValidationErrors)
                    {
                        Trace.TraceInformation("Property: {0} Error: {1}",
                                                validationError.PropertyName,
                                                validationError.ErrorMessage);
                    }
                }
            }
            return ret;
        }
Example #3
0
        private void ConvertUserToUserBDO(User user, UserBDO userBDO) {
            UserTypeBDO ut = new UserTypeBDO();
            ut.UserTypeCode = user.UserTypeCode;

            userBDO.UserId = user.UserId;
            userBDO.FirstName = user.FirstName;
            userBDO.LastName = user.LastName;
            userBDO.MiddleName = user.MiddleName;
            userBDO.UserName = user.UserName;
            userBDO.Password = user.Password;
            userBDO.Deactivated = user.Deactivated;
            userBDO.UserType = ut;

        }