예제 #1
0
        public ActionResult UserInfo(int pageId, helperUserInfo pageHelper)
        {
            pageShared ps = new pageShared(db);
            userShared us = new userShared(db);
            addressShared ash = new addressShared(db);

            var pageItem = ps.getPageById(pageId);
            var mainAccountPage = db.tbl_page.Include("tbl_category").Where(a => a.pageTypeId == (int)pageType.account).FirstOrDefault();

            ps.pageTitleBind(pageItem, pageHelper, langId);
            pageHelper.setTitle(pageItem.name);
            pageHelper.detail = pageItem.detail;

            pageHelper.leftMenuList = generateLeftMenu(mainAccountPage, pageItem.url);
            pageHelper.breadCrumbItem = getBreadCrumbTwoPage(mainAccountPage.name, mainAccountPage.url, pageItem.name, pageItem.url);
            pageHelper.cancelUrl = langCode + "/" + mainAccountPage.url + ".html";

            DateTime birthday = DateTime.Now;

            try
            {
                birthday = new DateTime(pageHelper.year, pageHelper.month, pageHelper.day);
            }
            catch
            {
                ModelState.AddModelError("validDate", lang.formValidDate);
            }

            try
            {
                System.Net.Mail.MailAddress mailItem = new System.Net.Mail.MailAddress(pageHelper.email);
            }
            catch
            {
                ModelState.AddModelError("email", lang.formValidEmail);
            }

            if (ModelState.IsValid)
            {
                topCart cartItem = (topCart)ViewData["topCart"];
                var userItem = us.getUserById(cartItem.userId);

                try
                {
                    userItem.birthday = birthday;
                    userItem.email = pageHelper.email;
                    userItem.gender = pageHelper.gender;
                    userItem.name = pageHelper.name;
                    userItem.surname = pageHelper.surname;
                    db.SaveChanges();

                    pageHelper.message = getSuccesMessage(lang.userInfoUpdated, "autoHide");
                    pageHelper.isMessageExist = true;
                }
                catch (Exception ex)
                {
                    errorSend(ex, "userAccountUpdate", true);
                }

            }
            else
            {
                string messages = string.Join("<br/> ", ModelState.Values
                                        .SelectMany(x => x.Errors)
                                        .Select(x => x.ErrorMessage));

                pageHelper.message = getErrorMessage(messages, "autoHide");
                pageHelper.isMessageExist = true;
            }

            return View(pageHelper);
        }
예제 #2
0
        public ActionResult UserInfo(int pageId)
        {
            pageShared ps = new pageShared(db);
            userShared us = new userShared(db);
            addressShared ash = new addressShared(db);

            var pageItem = ps.getPageById(pageId);
            var mainAccountPage = db.tbl_page.Include("tbl_category").Where(a => a.pageTypeId == (int)pageType.account).FirstOrDefault();

            topCart cartItem = (topCart)ViewData["topCart"];

            helperUserInfo pageHelper = new helperUserInfo();

            ps.pageTitleBind(pageItem, pageHelper, langId);
            pageHelper.setTitle(pageItem.name);
            pageHelper.detail = pageItem.detail;

            pageHelper.leftMenuList = generateLeftMenu(mainAccountPage, pageItem.url);
            pageHelper.breadCrumbItem = getBreadCrumbTwoPage(mainAccountPage.name, mainAccountPage.url, pageItem.name, pageItem.url);

            var userItem = us.getUserById(cartItem.userId);

            pageHelper.name = userItem.name;
            pageHelper.surname = userItem.surname;
            pageHelper.email = userItem.email;

            if (userItem.birthday.HasValue)
            {
                var birthday = userItem.birthday.Value;

                pageHelper.day = birthday.Day;
                pageHelper.month = birthday.Month;
                pageHelper.year = birthday.Year;
            }

            if (userItem.gender.HasValue)
            {
                pageHelper.gender = userItem.gender.Value;
            }

            pageHelper.cancelUrl = langCode + "/" + mainAccountPage.url + ".html";

            return View(pageHelper);
        }