コード例 #1
0
        public async Task <IActionResult> CreateRecipient([FromBody] RecipientForCreateDto input)
        {
            if (ModelState.IsValid)
            {
                // var userId = GetUserId();
                var userEmail = GetUserEmail();
                if (userEmail == "error")
                {
                    return(Unauthorized(new { message = "Unauthorized" }));
                }
                var recipient = _mapper.Map <Recipient>(input);
                //recipient.ApplicationUserID = userId;
                recipient.Email = userEmail;
                var result = await _recipientService.CreateRecipient(recipient);

                if (result)
                {
                    return(Ok(new { message = "Thêm người nhận thành công!" }));
                }
            }
            return(BadRequest(new { message = "Invalid recipient" }));
        }