public long UpdateUser(UserAccountModel model)
        {
            long res = 0;
            // Declare new DataAccess object
            ManageUserDa dataAccess = new ManageUserDa();

            using (var transaction = new TransactionScope())
            {
                TblUserAccount entity = new TblUserAccount();
                entity.USER_ID                   = model.USER_ID = model.USER_ID_HIDDEN;
                entity.USER_NAME                 = model.USER_NAME;
                entity.SHOP_NAME                 = model.SHOP_NAME;
                entity.AREA                      = model.AREA;
                entity.USER_AUTHORITY            = model.USER_AUTHORITY;
                entity.USER_CITY                 = model.USER_CITY;
                entity.USER_DISTRICT             = model.USER_DISTRICT;
                entity.USER_TOWN                 = model.USER_TOWN;
                entity.USER_ADDRESS              = model.USER_ADDRESS;
                entity.USER_PHONE                = model.USER_PHONE;
                entity.LOGIN_LOCK_FLG            = model.LOGIN_LOCK_FLG;
                entity.DEL_FLG                   = DeleteFlag.NON_DELETE;
                entity.STATUS                    = model.STATUS;
                entity.INS_DATE                  = Utility.GetCurrentDateTime();
                entity.PASSWORD_LAST_UPDATE_DATE = Utility.GetCurrentDateTime();
                entity.UPD_DATE                  = Utility.GetCurrentDateTime();

                res = dataAccess.UpdateUser(entity);
                if (res <= 0)
                {
                    transaction.Dispose();
                }
                transaction.Complete();
            }
            return(res);
        }
Beispiel #2
0
        public ActionResult ResetPassword(UserAccountModel model)
        {
            if (ModelState.IsValid)
            {
                using (UserAccountService service = new UserAccountService())
                {
                    ManageUserDa dataAccess = new ManageUserDa();

                    var UserId = dataAccess.selectUserId(model.USER_EMAIL);
                    if (UserId > 0)
                    {
                        var suscess = dataAccess.ReSetPassword(UserId);
                        sendMailResetPassword(model.USER_EMAIL);
                        if (suscess > 0)
                        {
                            ViewBag.sendMailSuccess = "Yêu cầu reset mật khẩu của bạn đã được gửi tới email:" + model.USER_EMAIL;
                        }
                        return(this.View());
                    }
                }
            }
            {
                var errors = ModelState.Where(x => x.Value.Errors.Count > 0).Select(x => new { x.Key, x.Value.Errors }).ToArray();
            }

            return(View());
        }
        public IEnumerable <TblUserAccountEx> SearchUserList(DataTableModel dt, UserAccountModel model, out int total_row)
        {
            ManageUserDa dataAccess = new ManageUserDa();
            IEnumerable <TblUserAccountEx> results = dataAccess.SearchUserList(dt, model, out total_row);

            return(results);
        }
        public bool DeleteUser(long USER_ID = 0)
        {
            ManageUserDa dataAccess = new ManageUserDa();

            int result = 0;

            using (var transaction = new TransactionScope())
            {
                try
                {
                    result = dataAccess.DeleteUser(USER_ID);

                    if (result > 0)
                    {
                        transaction.Complete();
                    }
                }
                catch (Exception ex)
                {
                    transaction.Dispose();
                    result = -1;
                    throw new Exception(ex.Message, ex);
                }
                finally
                {
                    transaction.Dispose();
                }
            }

            return(result > 0);
        }
Beispiel #5
0
        // check exist user
        public ActionResult CheckExistUserAccount(string userAccount)
        {
            // Declare new DataAccess object
            ManageUserDa dataAccess = new ManageUserDa();

            var exist = dataAccess.CheckExistUserAccount(userAccount);

            return(new EmptyResult());
        }
Beispiel #6
0
        public ActionResult UserEdit(long UserId = 0)
        {
            CmnEntityModel currentUser   = Session["CmnEntityModel"] as CmnEntityModel;
            var            authorityList = currentUser != null ? currentUser.USER_AUTHORITY : 0;

            if (currentUser == null || authorityList != 2)
            {
                return(RedirectToAction("Login", "UserAccount"));
            }

            UserAccountModel model = new UserAccountModel();

            CommonService comService = new CommonService();
            ManageUserDa  dataAccess = new ManageUserDa();

            if (UserId > 0)
            {
                UserAccountModel infor = new UserAccountModel();
                infor = dataAccess.getInfoUser(UserId);
                model = infor != null ? infor : model;
                model.DISTRICT_CD_KEY = model.USER_CITY.ToString() + "_" + model.USER_DISTRICT.ToString();
                model.TOWN_CD_KEY     = model.USER_CITY.ToString() + "_" + model.USER_DISTRICT.ToString() + "_" + model.USER_TOWN.ToString();
            }

            model.CITY_LIST = comService.GetCityList().ToList().Select(
                f => new SelectListItem
            {
                Value = f.CITY_CD.ToString(),
                Text  = f.CITY_NAME
            }).ToList();
            model.CITY_LIST.Insert(0, new SelectListItem {
                Value = Constant.DEFAULT_VALUE, Text = ""
            });

            model.DISTRICT_LIST = comService.GetDistrictList().ToList().Select(
                f => new SelectListItem
            {
                Value = f.CITY_CD.ToString() + "_" + f.DISTRICT_CD.ToString(),
                Text  = f.DISTRICT_NAME
            }).ToList();

            model.TOWN_LIST = comService.GetTownList().ToList().Select(
                f => new SelectListItem
            {
                Value = f.CITY_CD.ToString() + "_" + f.DISTRICT_CD.ToString() + "_" + f.TOWN_CD.ToString(),
                Text  = f.TOWN_NAME
            }).ToList();

            ViewBag.UserAuthority = new SelectList(UtilityServices.UtilityServices.GetAuthorityUser(), "Value", "Text");


            return(View(model));
        }
Beispiel #7
0
        public ActionResult UserList()
        {
            CmnEntityModel currentUser   = Session["CmnEntityModel"] as CmnEntityModel;
            var            authorityList = currentUser != null ? currentUser.USER_AUTHORITY : 0;

            if (currentUser == null || authorityList != 2)
            {
                return(RedirectToAction("Login", "UserAccount"));
            }

            UserAccountModel model = new UserAccountModel();

            CommonService comService = new CommonService();
            ManageUserDa  dataAccess = new ManageUserDa();

            var tmpCondition = GetRestoreData() as UserAccountModel;

            if (tmpCondition != null)
            {
                model = tmpCondition;
            }
            model.CITY_LIST = comService.GetCityList().ToList().Select(
                f => new SelectListItem
            {
                Value = f.CITY_CD.ToString(),
                Text  = f.CITY_NAME
            }).ToList();
            model.CITY_LIST.Insert(0, new SelectListItem {
                Value = Constant.DEFAULT_VALUE, Text = ""
            });

            model.DISTRICT_LIST = comService.GetDistrictList().ToList().Select(
                f => new SelectListItem
            {
                Value = f.CITY_CD.ToString() + "_" + f.DISTRICT_CD.ToString(),
                Text  = f.DISTRICT_NAME
            }).ToList();

            model.TOWN_LIST = comService.GetTownList().ToList().Select(
                f => new SelectListItem
            {
                Value = f.CITY_CD.ToString() + "_" + f.DISTRICT_CD.ToString() + "_" + f.TOWN_CD.ToString(),
                Text  = f.TOWN_NAME
            }).ToList();

            ViewBag.UserAuthority = new SelectList(UtilityServices.UtilityServices.GetAuthorityUser(), "Value", "Text");

            return(View(model));
        }
Beispiel #8
0
        public ActionResult Register(long UserId = 0)
        {
            UserAccountModel model = new UserAccountModel();

            CommonService comService = new CommonService();
            ManageUserDa  dataAccess = new ManageUserDa();

            if (UserId > 0)
            {
                UserAccountModel infor = new UserAccountModel();
                infor = dataAccess.getInfoUser(UserId);
                model = infor != null ? infor : model;
                model.DISTRICT_CD_KEY = model.USER_CITY.ToString() + "_" + model.USER_DISTRICT.ToString();
                model.TOWN_CD_KEY     = model.USER_CITY.ToString() + "_" + model.USER_DISTRICT.ToString() + "_" + model.USER_TOWN.ToString();
            }

            model.CITY_LIST = comService.GetCityList().ToList().Select(
                f => new SelectListItem
            {
                Value = f.CITY_CD.ToString(),
                Text  = f.CITY_NAME
            }).ToList();
            model.CITY_LIST.Insert(0, new SelectListItem {
                Value = Constant.DEFAULT_VALUE, Text = "Tỉnh/thành phố"
            });

            model.DISTRICT_LIST = comService.GetDistrictList().ToList().Select(
                f => new SelectListItem
            {
                Value = f.CITY_CD.ToString() + "_" + f.DISTRICT_CD.ToString(),
                Text  = f.DISTRICT_NAME
            }).ToList();
            model.DISTRICT_LIST.Insert(0, new SelectListItem {
                Value = Constant.DEFAULT_VALUE, Text = "Quận/huyện"
            });

            model.TOWN_LIST = comService.GetTownList().ToList().Select(
                f => new SelectListItem
            {
                Value = f.CITY_CD.ToString() + "_" + f.DISTRICT_CD.ToString() + "_" + f.TOWN_CD.ToString(),
                Text  = f.TOWN_NAME
            }).ToList();
            model.TOWN_LIST.Insert(0, new SelectListItem {
                Value = Constant.DEFAULT_VALUE, Text = "Xã/phường"
            });

            return(View(model));
        }
Beispiel #9
0
        // check exist user
        public ActionResult CheckExistUserAccount(string userEmail)
        {
            if (Request.IsAjaxRequest())
            {
                // Declare new DataAccess object
                ManageUserDa dataAccess = new ManageUserDa();

                var        exist  = dataAccess.CheckExistUserAccount(userEmail);
                JsonResult result = Json(new
                {
                    exist
                }, JsonRequestBehavior.AllowGet);

                return(result);
            }
            return(new EmptyResult());
        }
Beispiel #10
0
        public ActionResult ChangePassword(long UserId = 0)
        {
            UserAccountModel model = new UserAccountModel();

            CommonService comService = new CommonService();
            ManageUserDa  dataAccess = new ManageUserDa();

            if (UserId > 0)
            {
                UserAccountModel infor = new UserAccountModel();
                infor = dataAccess.getInfoUser(UserId);
                model = infor != null ? infor : model;
            }


            return(View(model));
        }
Beispiel #11
0
        // check exist user
        public ActionResult ConfirmResetPassword(string UserEmail)
        {
            // Declare new DataAccess object
            ManageUserDa dataAccess = new ManageUserDa();

            var UserId = dataAccess.selectUserId(UserEmail);

            if (UserId > 0)
            {
                var suscess = dataAccess.ConfirmEmail(UserId);
                if (suscess)
                {
                    return(this.RedirectToAction("Login", "UserAccount"));
                }
            }

            return(new EmptyResult());
        }
        public long InsertUser(UserAccountModel model)
        {
            long res = 0;
            // Declare new DataAccess object
            ManageUserDa dataAccess = new ManageUserDa();

            using (var transaction = new TransactionScope())
            {
                TblUserAccount entity = new TblUserAccount();
                entity.USER_EMAIL                = model.USER_EMAIL;
                entity.EMAIL_CONFIRMED           = EmailConfirmed.None;
                entity.USER_NAME                 = model.USER_NAME;
                entity.SHOP_NAME                 = model.SHOP_NAME;
                entity.USER_PASSWORD             = SafePassword.GetSaltedPassword(model.USER_PASSWORD);
                entity.PASSWORD_LAST_UPDATE_DATE = Utility.GetCurrentDateTime();
                entity.USER_AUTHORITY            = model.USER_AUTHORITY;
                entity.AREA           = model.AREA;
                entity.USER_CITY      = model.USER_CITY;
                entity.USER_DISTRICT  = model.USER_DISTRICT;
                entity.USER_TOWN      = model.USER_TOWN;
                entity.USER_ADDRESS   = model.USER_ADDRESS;
                entity.USER_PHONE     = model.USER_PHONE;
                entity.USER_FAMILY    = 0;
                entity.LOGIN_LOCK_FLG = LockFlag.NON_LOCK;
                entity.GENDER         = true;
                entity.DEL_FLG        = DeleteFlag.NON_DELETE;
                entity.STATUS         = model.STATUS;
                entity.INS_DATE       = Utility.GetCurrentDateTime();
                entity.UPD_DATE       = Utility.GetCurrentDateTime();

                res = dataAccess.InsertUser(entity);
                if (res <= 0)
                {
                    transaction.Dispose();
                }
                transaction.Complete();
            }
            return(res);
        }