Beispiel #1
0
        /// <summary>
        /// Attendee's page to update their own profile, Limited editing page
        /// </summary>
        /// <param name="id">Person Id for admin editing</param>
        /// <returns></returns>
        public ActionResult Edit(Guid?id)
        {
            User user;

            // admin is trying to edit, authorize them
            if (id.HasValue)
            {
                user = _userRepository.GetNullableById(id.Value);

                // current user must be in User role)
                if (!Roles.IsUserInRole(RoleNames.User))
                {
                    return(this.RedirectToAction <ErrorController>(a => a.NotAuthorized()));
                }
            }
            else
            {
                user = Repository.OfType <User>().Queryable.Where(a => a.LoweredUserName == CurrentUser.Identity.Name.ToLower()).FirstOrDefault();
            }

            if (user == null)
            {
                return(this.RedirectToAction <ErrorController>(a => a.NotAuthorized()));
            }

            var person = user.Person;

            var viewModel = PersonViewModel.Create(Repository, _firmService, Site, null, person, user.Email);

            return(View(viewModel));
        }
Beispiel #2
0
        /// <summary>
        /// Create an account from Information Request
        /// </summary>
        /// <param name="id">Information Request Id</param>
        /// <returns></returns>
        public ActionResult CreatePerson(int id)
        {
            var ir = _informationrequestRepository.GetNullableById(id);

            if (ir == null)
            {
                Message = string.Format(Messages.NotFound, "information request", id);
                return(this.RedirectToAction(a => a.Index()));
            }

            var viewModel = PersonViewModel.Create(Repository, _firmService, Site);

            viewModel.Person.FirstName = ir.FirstName.Trim();
            viewModel.Person.LastName  = ir.LastName.Trim();
            viewModel.Email            = ir.Email;
            viewModel.UserName         = string.Format("{0}.{1}", ir.FirstName.Trim(), ir.LastName.Trim());

            // fake phone number
            viewModel.Person.Phone = ir.Phone;

            var atype = _addressTypeRepository.GetNullableById((char)StaticIndexes.Address_Business[0]);

            var address = viewModel.Addresses.FirstOrDefault(a => a.AddressType == atype);

            if (address != null)
            {
                address.Line1   = ir.AddressLine1;
                address.Line2   = ir.AddressLine2;
                address.City    = ir.City;
                address.State   = ir.State;
                address.Zip     = ir.Zip;
                address.Country = ir.Country;
            }

            if (ir.Site.CollectExtended)
            {
                // get the assistant contact
                var ctype     = RepositoryFactory.ContactTypeRepsitory.GetNullableById((char)StaticIndexes.Contact_Assistant[0]);
                var assistant = viewModel.Contacts.FirstOrDefault(a => a.ContactType == ctype);

                if (assistant != null)
                {
                    assistant.FirstName = ir.AssistantFirstName;
                    assistant.LastName  = ir.AssistantLastName;
                    assistant.Email     = ir.AssistantEmail;
                    assistant.Phone     = ir.AssistantPhone;

                    var comoption = RepositoryFactory.CommunicationOptionRepository.GetNullableById(StaticIndexes.Communication_Assistant);
                    viewModel.Person.CommunicationOption = comoption;
                }
            }
            else
            {
                var comoption = RepositoryFactory.CommunicationOptionRepository.GetNullableById(StaticIndexes.Communication_Directly);
                viewModel.Person.CommunicationOption = comoption;
            }

            return(View(viewModel));
        }
Beispiel #3
0
        public ActionResult Edit(Guid?id, PersonEditModel personEditModel, HttpPostedFileBase profilepic)
        {
            User user = null;

            // admin is trying to edit, authorize them
            if (id.HasValue)
            {
                // current user must be in User role
                if (Roles.IsUserInRole(RoleNames.User))
                {
                    user = _userRepository.GetNullableById(id.Value);
                }
            }
            else
            {
                user = Repository.OfType <User>().Queryable.Where(a => a.LoweredUserName == CurrentUser.Identity.Name.ToLower()).FirstOrDefault();
            }

            if (user == null)
            {
                return(this.RedirectToAction <ErrorController>(a => a.NotAuthorized()));
            }

            //var seminarPerson = _seminarPersonRepository.GetNullableById(personEditModel.SeminarPersonId);
            var person = SetPerson(personEditModel, null, ModelState, user.Person, profilepic);

            var membership = user.Membership;

            membership.SetEmail(personEditModel.Email);

            if (ModelState.IsValid)
            {
                _personRepository.EnsurePersistent(person);
                _membershipRepository.EnsurePersistent(membership);

                Message = string.Format(Messages.Saved, "Person");

                if (personEditModel.UserName != CurrentUser.Identity.Name.ToLower())
                {
                    user.SetUserName(personEditModel.UserName);
                    _userRepository.EnsurePersistent(user);

                    var formsService = new FormsAuthenticationService();
                    formsService.SignOut();
                    formsService.SignIn(user.LoweredUserName, false);
                }

                // send to crop photo if one was uploaded
                if (profilepic != null)
                {
                    return(this.RedirectToAction(a => a.UpdateProfilePicture(person.Id, null, true)));
                }
            }

            var viewModel = PersonViewModel.Create(Repository, _firmService, Site, null, person, user.Email);

            return(View(viewModel));
        }
Beispiel #4
0
        public ActionResult CreatePerson(int id, PersonEditModel personEditModel, HttpPostedFileBase profilepic)
        {
            ModelState.Clear();

            var person = personEditModel.Person;

            var user = _userRepository.Queryable.FirstOrDefault(a => a.LoweredUserName == personEditModel.UserName.ToLower());

            person.User = user;

            SeminarPerson seminarPerson = null;

            person = SetPerson(personEditModel, seminarPerson, ModelState, person, profilepic);

            ModelState.Remove("Person.User");

            if (ModelState.IsValid)
            {
                // try to create the user
                var createStatus = _membershipService.CreateUser(personEditModel.UserName
                                                                 , Guid.NewGuid().ToString().Replace("-", string.Empty).Substring(0, 10)
                                                                 , personEditModel.Email);

                // retrieve the user to assign
                var createdUser = _userRepository.Queryable.FirstOrDefault(a => a.LoweredUserName == personEditModel.UserName.ToLower());
                person.User = createdUser;

                // save only if user creation was successful
                if (createStatus == MembershipCreateStatus.Success)
                {
                    person.AddSite(SiteService.LoadSite(Site));

                    // we're good save the person object
                    _personRepository.EnsurePersistent(person);
                    Message = string.Format(Messages.Saved, "Person");

                    if (person.OriginalPicture != null)
                    {
                        return(this.RedirectToAction <PersonController>(a => a.UpdateProfilePicture(person.Id, null, false)));
                    }

                    return(this.RedirectToAction <PersonController>(a => a.AdminEdit(person.User.Id, null, true)));
                }

                ModelState.AddModelError("Create User", AccountValidation.ErrorCodeToString(createStatus));
            }

            var viewModel = PersonViewModel.Create(Repository, _firmService, Site, null, person, personEditModel.Email);

            viewModel.Addresses = personEditModel.Addresses;
            viewModel.UserName  = personEditModel.UserName;
            return(View(viewModel));
        }
Beispiel #5
0
        public ActionResult Create(int?id)
        {
            var seminar = _seminarRepository.GetNullableById(id.HasValue ? id.Value : 0);

            //if (seminar == null)
            //{
            //    Message = string.Format(Messages.NotFound, "seminar", id);
            //    return this.RedirectToAction<SeminarController>(a => a.Index());
            //}

            ViewData["site"] = Site;

            var viewModel = PersonViewModel.Create(Repository, _firmService, Site, seminar);

            return(View(viewModel));
        }
Beispiel #6
0
        public ActionResult Create([Bind(Include = "Id,Nationality_Id,FullName,Father,Mother,Age,BirthDate,Height,Weight,PlaceBirth,Adress,Residence_Country_Id,SocialStatus,Color,Gender,Photo1,Photo2,User_Id,NationalityNumber,PassportNumber,Email,IsActive,Phone1,Phone2,GeneralInfo,NickName,SurName,CountryState,ChildCount,MaxChildAge,MinChildAge,Education,EducationBranch,WorkType,Languages,LivingLevel,Theams,Hobbies,Culture,CultureLevel,Residence_Country,FullName_IsHidden,NickName_IsHidden,SurName_IsHidden,Phone1_IsHidden,Phone2_IsHidden,Email_IsHidden,Adress_IsHidden,Theams_IsHidden,Photo1_IsHidden,Photo2_IsHidden,Color_IsHidden,Weight_IsHidden,Height_IsHidden")] PersonViewModel personViewModel)
        {
            if (ModelState.IsValid)
            {
                personViewModel.Gender = genderType;
                personViewModel.Create();
                personViewModel.SaveCustomizeFlds();

                // Added BY N
                RegisterRequestViewModels RR = new RegisterRequestViewModels();
                RR.Person_Id       = personViewModel.Id;
                RR.RequestStatus   = 0;
                RR.RequestDate     = DateTime.Now;
                RR.ResponseMessage = 1;
                RR.Create();

                TempData["Caller"] = "PersonSaved";
                return(RedirectToAction("Unauthorized", "Home", null));
                //return Content("<script language='javascript' type='text/javascript'>alert('تم حفظ بياناتك');</script>");
            }


            return(View(personViewModel));
        }