Exemplo n.º 1
0
        public ActionResult AddNewMember(string ProfileFirstName, string ProfileLastName, string ProfileGender,
            string ProfileDegree, string ProfileNationalityCode, string ProfileShenasnameCode, string ProfileShenasnamePlace,
            string ProfilePersonID, string ProfileBirthdateDay, string ProfileBirthdateMonth, string ProfileBirthdateYear,
            string ProfileMobile, string ProfileHomePhone, string ProfileWorkPhone, string ProfileEmail, string ProfileCity,
            string NewMemberEmployeeDateDay, string NewMemberEmployeeDateYear, string NewMemberEmployeeDateMonth,
            string NewMemberContractType, string NewMemberJobType, string NewMemberJobConcept, string NewMemberJobStatus,
            string NewMemberJob3University, string NewMemberIsargariType, string NewMemberEsratDuration,
            string NewMemberJanbaziPercent, string NewMemberJebheDuration, string NewMemberIsargariIsargarFamilyType,
            string NewMemberPictureName, string NewMemberjobName, string NewMemberJobPlace, bool NewMemberIsAzadeh, string NewMemberOthertype,
            bool NewMemberIsJanbaz, bool NewMemberIsRazmande, bool NewMemberIsIsargar, bool NewMemberIsFamilyOfShahid, bool NewMemberIsChildOfShahid)
        {
            try
            {
                #region Create User
                String userName = ProfileNationalityCode;
                String password = userName;
                String email = ProfileEmail;
                MembershipCreateStatus createStatus = MembershipService.CreateUser(userName, password, email);
                if (createStatus == MembershipCreateStatus.Success)
                {
                    Roles.AddUserToRole(userName, "Member");
                }
                else
                {
                    return Error(((int)createStatus) + 10);
                }

                var user = Membership.GetUser(userName);
                m_model.aspnet_Users.Single(P => P.UserName.Equals(userName)).aspnet_Membership.IsApproved = false;

                var userId = m_model.aspnet_Users.Single(P => P.UserName.Equals(user.UserName)).UserId;
                #endregion
                #region Add Profile
                MembersProfile profile = new MembersProfile();
                profile.MemberID = userId;
                profile.PersonalNumber = ProfilePersonID;
                profile.LastName = ProfileLastName;
                profile.FirstName = ProfileFirstName;
                profile.DegreeID = int.Parse(ProfileDegree);
                profile.CityID = int.Parse(ProfileCity);
                profile.BirthDate = ProfileBirthdateYear + ":" + ProfileBirthdateMonth + ":" + ProfileBirthdateDay;
                profile.Gender = int.Parse(ProfileGender) == 0 ? false : true;
                profile.IDCard = ProfileShenasnameCode;
                profile.IDCardPlace = ProfileShenasnamePlace;
                profile.InternationalCode = ProfileNationalityCode;
                profile.CreateDate = GetPersianDate(DateTime.Now);
                m_model.MembersProfiles.InsertOnSubmit(profile);
                #endregion
                #region Add Employee
                MembersEmployee employee = new MembersEmployee();
                employee.Contract = int.Parse(NewMemberContractType);
                employee.From = NewMemberEmployeeDateYear + ":" + NewMemberEmployeeDateMonth + ":" + NewMemberEmployeeDateDay;
                employee.Job = int.Parse(NewMemberJobType);
                employee.JobState = int.Parse(NewMemberJobStatus);
                employee.MemberID = userId;
                employee.Organization = int.Parse(NewMemberJobConcept);
                employee.University = int.Parse(NewMemberJob3University);
                employee.JobOtherType = int.Parse(NewMemberOthertype);
                employee.JobName = NewMemberjobName;
                employee.JobPlace = NewMemberJobPlace;

                m_model.MembersEmployees.InsertOnSubmit(employee);
                #endregion
                #region Isargari
                if (NewMemberIsAzadeh)
                {
                    MembersIsargari isargari = new MembersIsargari();
                    isargari.MemberID = userId;
                    isargari.IsargariType = 1;
                    isargari.IsargariValue = NewMemberEsratDuration;
                    m_model.MembersIsargaris.InsertOnSubmit(isargari);
                }
                if (NewMemberIsChildOfShahid)
                {
                    MembersIsargari isargari = new MembersIsargari();
                    isargari.MemberID = userId;
                    isargari.IsargariType = 6;
                    m_model.MembersIsargaris.InsertOnSubmit(isargari);
                }
                if (NewMemberIsFamilyOfShahid)
                {
                    MembersIsargari isargari = new MembersIsargari();
                    isargari.MemberID = userId;
                    isargari.IsargariType = 5;
                    m_model.MembersIsargaris.InsertOnSubmit(isargari);
                }
                if (NewMemberIsJanbaz)
                {
                    MembersIsargari isargari = new MembersIsargari();
                    isargari.MemberID = userId;
                    isargari.IsargariType = 2;
                    isargari.IsargariValue = NewMemberJanbaziPercent;
                    m_model.MembersIsargaris.InsertOnSubmit(isargari);
                }
                if (NewMemberIsIsargar)
                {
                    MembersIsargari isargari = new MembersIsargari();
                    isargari.MemberID = userId;
                    isargari.IsargariType = 4;
                    isargari.IsargarRelation = NewMemberIsargariIsargarFamilyType;
                    m_model.MembersIsargaris.InsertOnSubmit(isargari);
                }
                else if (NewMemberIsRazmande)
                {
                    MembersIsargari isargari = new MembersIsargari();
                    isargari.MemberID = userId;
                    isargari.IsargariType = 3;
                    isargari.IsargariValue = NewMemberJebheDuration;
                    m_model.MembersIsargaris.InsertOnSubmit(isargari);
                }
                #endregion
                #region Contacts
                MemberContact contacts = new MemberContact();
                contacts.Email = ProfileEmail;
                contacts.HomePhone = ProfileHomePhone;
                contacts.WorkPhone = ProfileWorkPhone;
                contacts.MobilePhone = ProfileMobile;
                contacts.MemberID = userId;
                m_model.MemberContacts.InsertOnSubmit(contacts);
                #endregion

                m_model.SubmitChanges();

                #region Apply Picture
                String lastName = Path.Combine(Server.MapPath("~/Pics/Users/Originals"), NewMemberPictureName);
                String newName = Path.Combine(Server.MapPath("~/Pics/Users/Originals"), userName + ".png");
                FileInfo f = new FileInfo(lastName);
                if (new FileInfo(newName).Exists)
                    System.IO.File.Delete(newName);
                if (f.Exists)
                {
                    System.IO.File.Copy(lastName, newName);
                    System.IO.File.Delete(lastName);
                }

                lastName = Path.Combine(Server.MapPath("~/Pics/Users/Thumbnails"), NewMemberPictureName);
                newName = Path.Combine(Server.MapPath("~/Pics/Users/Thumbnails"), userName + ".png");
                f = new FileInfo(lastName);
                if (new FileInfo(newName).Exists)
                    System.IO.File.Delete(newName);
                if (f.Exists)
                {
                    System.IO.File.Copy(lastName, newName);
                    System.IO.File.Delete(lastName);
                }
                #endregion
                return Success(33);
            }
            catch (Exception ex)
            {
                if (Membership.GetUser(ProfileNationalityCode) != null)
                    Membership.DeleteUser(ProfileNationalityCode);
                return Json(new { Status = false, Message = ex.Message }, JsonRequestBehavior.AllowGet);
            }
        }
Exemplo n.º 2
0
 partial void DeleteMembersEmployee(MembersEmployee instance);
Exemplo n.º 3
0
 partial void InsertMembersEmployee(MembersEmployee instance);
Exemplo n.º 4
0
 partial void UpdateMembersEmployee(MembersEmployee instance);
Exemplo n.º 5
0
		private void detach_MembersEmployees(MembersEmployee entity)
		{
			this.SendPropertyChanging();
			entity.aspnet_User = null;
		}