コード例 #1
0
        public IActionResult CallEditUser(string nameUser, string pin, string oldUser)
        {
            try
            {
                string email = HttpContext.Session.GetString("Email");
                if (String.IsNullOrEmpty(email))
                {
                    return(RedirectToAction("Index", "Register"));
                }

                email = email.ToLower();
                bool isEmail = _authService.ChechEmail(email);
                if (!isEmail)
                {
                    return(RedirectToAction("Error", "Management", new { message = "E-Mail ไม่มีอยู่ในระบบโปรดลงทะเบียนใหม่" }));
                }

                CheckPinDtoCommand checkPinDto = new CheckPinDtoCommand()
                {
                    Email = email,
                    Pin   = pin
                };
                bool isPin = _authService.CheckPin(checkPinDto);
                if (isPin)
                {
                    return(RedirectToAction("Error", "Management", new { message = "Pin นี้ถูกใช้งานในร้านค้านี้เรียบร้อย" }));
                }

                CheckNameUserDtoCommand checkNameUser = new CheckNameUserDtoCommand()
                {
                    Email    = email,
                    NameUser = nameUser
                };
                bool isName = _authService.ChechNameUser(checkNameUser);
                if (isName)
                {
                    return(RedirectToAction("Error", "Management", new { message = "ชื่อพนักงานคนนี้ถูกใช้งานในร้านค้านี้เรียบร้อย" }));
                }

                EditUserInStoreDtoCommand command = new EditUserInStoreDtoCommand()
                {
                    Email    = email,
                    OldUser  = oldUser,
                    NameUser = nameUser,
                    Pin      = pin
                };
                bool isRegisUser = _authService.EditUserInStore(command);
                if (!isRegisUser)
                {
                    return(RedirectToAction("Error", "User", new { message = "ไม่สามารถแก้ไขพนักงานได้" }));
                }
                return(RedirectToAction("SuccessPage", "User", new { message = "แก้ไขพนักงานสำเร็จ" }));
            }
            catch (Exception e)
            {
                Console.WriteLine("Error : " + e.Message);
                return(RedirectToAction("Index", "Register"));
            }
        }
コード例 #2
0
        public bool EditUserInStore(EditUserInStoreDtoCommand command)
        {
            string email    = command.Email.ToLower();
            string pin      = command.Pin;
            string nameUser = command.NameUser;
            string oldUser  = command.OldUser;

            int storeId = _storeRepository.GetStoreIdByEmail(email);

            if (storeId == default || storeId == 0)
            {
                return(false);
            }

            return(_userRepository.EditUserInStore(storeId, pin, nameUser, oldUser));
        }