Пример #1
0
        public async Task <IActionResult> GetById([FromRoute] int id)
        {
            var city = await _crudPattern.Get(id);

            if (city == null)
            {
                return(NotFound());
            }
            return(Ok(city));
        }
Пример #2
0
        public async Task <IActionResult> GetById([FromRoute] int id)
        {
            var workLocation = await _crudPattern.Get(id);

            if (workLocation == null)
            {
                return(NotFound());
            }
            var result = _mapper.Map <WorkLocationReadDto>(workLocation);

            return(Ok(result));
        }
Пример #3
0
        public async Task <IActionResult> GetById([FromRoute] int id)
        {
            var user = await _crudPattern.Get(id);

            if (user == null)
            {
                return(NotFound());
            }
            var result = _mapper.Map <UserReadDto>(user);

            return(Ok(result));
        }
Пример #4
0
        public async Task <ErrorValidator> ChangePassword(int userId, ChangePasswordSaveDto resourceSave)
        {
            if (resourceSave.NewPassword != resourceSave.ConfirmNewPassword)
            {
                return(new ErrorValidator("Password Mismatch"));
            }
            var user = await _userRepo.Get(userId);

            if (user == null)
            {
                return(new ErrorValidator("User Doesn't Exist"));
            }
            if (user.Password == AES.Encrypt(resourceSave.NewPassword))
            {
                return(new ErrorValidator("Use Different Password, Detected that it is same as your current password!"));
            }
            _mapper.Map(resourceSave, user);
            if (!await _userRepo.SaveChanges())
            {
                return(new ErrorValidator("Password Fail to Change!!"));
            }
            return(new  ErrorValidator());
        }