コード例 #1
0
        public async Task <IActionResult> AddAnswer(int id, string comment)
        {
            try
            {
                if (String.IsNullOrEmpty(comment))
                {
                    return(Json(false));
                }
                var user = await _requestUserProvider.GetCurrentUserAsync();

                var commentModel = new Answer()
                {
                    Description = comment,
                    Date        = DateTime.Now,
                    AuthorId    = user.Id,
                    QuestionId  = id,
                };
                await _answersCommand.AnswerQuestion(commentModel, new CancellationToken());

                return(Json(true));
            }
            catch (Exception ex)
            {
                var msg = ex.Message;
                return(Json(false));
            }
        }
コード例 #2
0
        public Task UploadImage(IFormFile file)
        {
            var currentUser = _requestUserProvider.GetCurrentUserAsync().Result;

            if (currentUser == null)
            {
                throw new Exception("User not found");
            }

            currentUser.UserPhoto = ConvertToBytes(file);

            return(_questionGateway.UploadUserPhoto(currentUser));
        }