Esempio n. 1
0
        public static string AddAdmininDB(AdminManageDetail _newuser)
        {
            GuruETC.DB.GuruETCEntities _etc = new DB.GuruETCEntities();
            string msg = string.Empty;
            MembershipCreateStatus sts;
            try
            {
                Membership.CreateUser(_newuser.UserName, _newuser.Password, _newuser.Email, null, null, true, out sts);
                if (sts == MembershipCreateStatus.Success)
                {
                    MembershipUser _getUser = Membership.GetUser(_newuser.UserName);
                    if (_getUser != null)
                    {
                        Roles.AddUserToRole(_getUser.UserName, "Admin");
                        AdminProfile _prof = new AdminProfile() { UserGuid = (Guid)_getUser.ProviderUserKey, DOB = DateTime.Parse(_newuser.ADOB), Name = _newuser.UserName};
                        _etc.AddToAdminProfiles(_prof);
                        _etc.SaveChanges();
                        msg = "Success";

                    }
                }
            }
            catch(Exception ex)
            {
                throw ex;
            }

            return msg;
        }
 /// <summary>
 /// Create a new AdminProfile object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 public static AdminProfile CreateAdminProfile(global::System.Int64 id)
 {
     AdminProfile adminProfile = new AdminProfile();
     adminProfile.Id = id;
     return adminProfile;
 }
 /// <summary>
 /// Deprecated Method for adding a new object to the AdminProfiles EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToAdminProfiles(AdminProfile adminProfile)
 {
     base.AddObject("AdminProfiles", adminProfile);
 }