private void detach_tUsers(tUser entity)
		{
			this.SendPropertyChanging();
			entity.tRole = null;
		}
 partial void DeletetUser(tUser instance);
		private void attach_tUsers(tUser entity)
		{
			this.SendPropertyChanging();
			entity.tRole = this;
		}
 partial void InserttUser(tUser instance);
 partial void UpdatetUser(tUser instance);
		private void attach_tUsers1(tUser entity)
		{
			this.SendPropertyChanging();
			entity.tCategory1 = this;
		}
		private void detach_tUsers1(tUser entity)
		{
			this.SendPropertyChanging();
			entity.tCategory1 = null;
		}
        private MembershipUser MakeMembershipUser(tUser user)
        {
            object userID = user.IDUser;
            string username = user.UserName;
            string email = user.UserName;

            string passwordQuestion = String.Empty;
            //if (sqlDataReader.GetValue(3) != DBNull.Value)
            //{
            //    passwordQuestion = sqlDataReader.GetString(3);
            //}

            string comment = String.Empty;
            //if (sqlDataReader.GetValue(4) != DBNull.Value)
            //{
            //    comment = sqlDataReader.GetString(4);
            //}

            bool isApproved = (bool)user.Approved;
            bool isLockedOut = false;
            DateTime creationDate = (DateTime)user.DateAdded;

            DateTime lastLoginDate = new DateTime();
            if (user.LastLoginDate != null) {
                lastLoginDate = (DateTime)user.LastLoginDate;
            }

            DateTime lastActivityDate = DateTime.Now;//sqlDataReader.GetDateTime(9);
            DateTime lastPasswordChangedDate = DateTime.Now; // sqlDataReader.GetDateTime(10);

            DateTime lastLockedOutDate = new DateTime();
            //if (sqlDataReader.GetValue(11) != DBNull.Value)
            //{
            //    lastLockedOutDate = sqlDataReader.GetDateTime(11);
            //}

            MembershipUser membershipUser = new MembershipUser(
              this.Name,
             username,
             userID,
             email,
             passwordQuestion,
             comment,
             isApproved,
             isLockedOut,
             creationDate,
             lastLoginDate,
             lastActivityDate,
             lastPasswordChangedDate,
             lastLockedOutDate
              );

            return membershipUser;
        }
        public override MembershipUser CreateUser(string username, string password, string email, string passwordQuestion, string passwordAnswer, bool isApproved, object providerUserKey, out MembershipCreateStatus status)
        {
            _UserRep = BootStrapper.GetCurrentUserRepository();

            ValidatePasswordEventArgs args = new ValidatePasswordEventArgs(username, password, true);

            OnValidatingPassword(args);

            if (args.Cancel) {
                status = MembershipCreateStatus.InvalidPassword;
                return null;
            }

            if ((RequiresUniqueEmail && (GetUserNameByEmail(email) != String.Empty))) {
                status = MembershipCreateStatus.DuplicateEmail;
                return null;
            }

            MembershipUser membershipUser = GetUser(username, false);

            if (membershipUser == null) {
                System.DateTime createDate = DateTime.Now;

                tUser user = new tUser();
                user.UserName = username;
                user.Password = password;
                user.UserName = email;
                user.Approved = isApproved;
                //user.Address = "";
                //user.AdSoyad = "";
                //user.Avatar = "";
                //user.BirthDate = new DateTime(1900, 1, 1);
                //user.CellNo = "";
                //user.City = "";
                user.DateAdded = DateTime.Now;
                user.LastLoginDate = DateTime.Now;
                //user.Role = "User";
                //user.Semt = "";
                //user.TellNo = "";
                //user.UserStatus = (int)B2B.Core.Enums.enmUserStatus.Active;
                user.IDRole = (int) Enums.enmRoles.User;

                try {
                    _UserRep.InsertOrUpdate(user);
                    int result = 1;
                    if (result > 0) {
                        _UserRep.Save();
                        status = MembershipCreateStatus.Success;
                    } else {
                        status = MembershipCreateStatus.UserRejected;
                    }
                } catch (Exception err) {
                    //Add exception handling here.

                    status = MembershipCreateStatus.ProviderError;
                }

                return GetUser(username, false);
            } else {
                status = MembershipCreateStatus.DuplicateUserName;
            }

            return null;
        }
Beispiel #10
0
 public void InsertOrUpdate(tUser user)
 {
     if (user.IDUser == default(int)) {
         // New entity
         context.tUsers.InsertOnSubmit(user);
     } else {
         // Existing entity
         //context.USERs.Attach(user);
         //context.Entry(user).State = EntityState.Modified;
         tUser userToUpdate = Find(user.IDUser);
         if(userToUpdate!=null && userToUpdate.IDUser>0)
         {
             userToUpdate.IDRole = user.IDRole;
             userToUpdate.Password = user.Password;
             userToUpdate.LastLoginDate = user.LastLoginDate;
             userToUpdate.Approved = user.Approved;
             userToUpdate.IDPartnerCategory = user.IDPartnerCategory;
             userToUpdate.IDCity = user.IDCity;
         }
     }
     context.SubmitChanges();
 }
 public JsonResult EditAjax(tUser userData)
 {
     if (ModelState.IsValid) {
        _userRepository.InsertOrUpdate(userData);
        return Json(new {
            objectAddedName = userData.UserName,
            valid = true,
            Message = "User was updated Succesfully"
        });
        } else {
        return Json(new {
            objectAddedName = "",
            valid = false,
            Message = "Fill All Fields please"
        });
        }
 }
 public JsonResult CreateAjax(tUser user)
 {
     user.DateAdded = DateTime.Now;
        if (ModelState.IsValid) {
        _userRepository.InsertOrUpdate(user);
        return Json(new {
            objectAddedName = user.UserName,
            valid = true,
            Message = "User was added Succesfully"
        });
        } else {
        return Json(new {
            objectAddedName = "",
            valid = false,
            Message = "Fill All Fields please"
        });
        }
 }