Exemplo n.º 1
0
        public static pb_UserProfile GetUser()
        {
            var            userName    = WebMatrix.WebData.WebSecurity.CurrentUserName;
            bn_UserProfile userProfile = new bn_UserProfile();

            return(userProfile.GetByUserName(userName));
        }
Exemplo n.º 2
0
        public ActionResult p_UserContact(Guid userId)
        {
            bn_UserContact bnUserContact = new bn_UserContact();
            bn_UserProfile bnUserProfile = new bn_UserProfile();
            ps_UserContact model         = new ps_UserContact();

            model.UserProfile = bnUserProfile.GetById(userId);
            model.Contacts    = bnUserContact.GetByUserId(userId);

            return(View(model));
        }
Exemplo n.º 3
0
        public ActionResult Detail(Guid?id)
        {
            bn_UserProfile bnUser = new bn_UserProfile();
            pb_UserProfile model  = null;

            if (id.HasValue)
            {
                model = bnUser.GetById(id.Value);
            }
            return(View(model));
        }
Exemplo n.º 4
0
        public ActionResult AllUser(int page = 1)
        {
            bn_UserProfile bnUser       = new bn_UserProfile();
            int            numberOfPage = 24;

            ViewBag.CountPage = (bnUser.GetCountAll() / numberOfPage) + 1;
            page = page > 0 ? page : 1;
            page = page < ViewBag.CountPage ? page : ViewBag.CountPage;

            ViewBag.page = page;
            var model = bnUser.GetListInPage(page, numberOfPage);

            return(View(model));
        }
Exemplo n.º 5
0
        public ActionResult Edit(Guid?userId)
        {
            if (!userId.HasValue)
            {
                userId = ps_Membership.GetUser().UserId;
            }

            bn_UserProfile bnUserProfile = new bn_UserProfile();
            pb_UserProfile model         = new pb_UserProfile();

            model = bnUserProfile.GetById((Guid)userId);

            return(View(model));
        }
Exemplo n.º 6
0
        public ActionResult Index(Guid?userId)
        {
            if (!userId.HasValue)
            {
                userId = ps_Membership.GetUser().UserId;
            }

            bn_UserContact bnUserContact = new bn_UserContact();
            bn_UserProfile bnUserProfile = new bn_UserProfile();
            ps_UserContact model         = new ps_UserContact();

            model.Contacts    = bnUserContact.GetByUserId((Guid)userId);
            model.UserProfile = bnUserProfile.GetById((Guid)userId);

            return(View(model));
        }
Exemplo n.º 7
0
        public ActionResult Register(RegisterModel model)
        {
            if (ModelState.IsValid)
            {
                // Attempt to register the user
                try
                {
                    bn_UserProfile bnUserProfile = new bn_UserProfile();
                    if (!bnUserProfile.IsExists(model.Email))
                    {
                        //email is not exists.

                        var userId = Guid.NewGuid();
                        WebSecurity.CreateUserAndAccount(
                            model.Email,
                            model.Password,
                            new
                        {
                            UserId    = userId,
                            FirstName = model.FirstName.Trim(),
                            LastName  = model.LastName.Trim()
                        });

                        WebSecurity.Login(model.Email, model.Password);
                        return(RedirectToRoute("Pure"));
                    }
                    else
                    {
                        ModelState.AddModelError("", "This email is alrealy exists.");
                    }
                }
                catch (MembershipCreateUserException e)
                {
                    ModelState.AddModelError("", ErrorCodeToString(e.StatusCode));
                }
            }

            // If we got this far, something failed, redisplay form
            return(View(model));
        }
Exemplo n.º 8
0
        public ActionResult Edit(pb_UserProfile model)
        {
            if (ModelState.IsValid)
            {
                bn_UserProfile bnUserProfile = new bn_UserProfile();
                var            re            = bnUserProfile.Update(
                    ps_Membership.GetUser().UserId,
                    model.FirstName,
                    model.LastName,
                    model.DateOfBirth);

                if (re >= 0)
                {
                    return(RedirectToAction("Index", "User"));
                }
                else
                {
                    //can't udpate
                }
            }

            return(View(model));
        }
Exemplo n.º 9
0
        public List <pb_UserProfile> Filter()
        {
            bn_UserProfile bnUser = new bn_UserProfile(isLazy: false);

            return(bnUser.GetAll());
        }