コード例 #1
0
        public async Task <ApiResponse> AddUserOpinion(AddUserOpinionVm addUserOpinionVm)
        {
            var user = _unitOfWork.userRepository.FindByCondition(x => x.Id == addUserOpinionVm.ProfileUserId).FirstOrDefault();

            var opinion = _unitOfWork.userOpinionRepository.FindByCondition(x => x.ProfileUserId == addUserOpinionVm.ProfileUserId).ToList();

            if (user == null)
            {
                throw new MyNotFoundException(ApiResponseDescription.USER_NOT_FOUND);
            }

            addUserOpinionVm.DateAdded = DateTime.Now;

            var model = _mapper.Map <AddUserOpinionVm, UserOpinion>(addUserOpinionVm);

            _unitOfWork.userOpinionRepository.Create(model);

            await _unitOfWork.CompleteAsync();

            return(new ApiResponse(true));
        }
コード例 #2
0
 public async Task <IActionResult> AddUserOpinion([FromBody] AddUserOpinionVm addUserOpinionVm) =>
 Ok(await _userOpinionService.AddUserOpinion(addUserOpinionVm));