public async Task <IActionResult> UpdateName(StudentUpdate.Command command)
        {
            var student = await _context.Students.FindAsync(command.Id);

            command.Note = student?.Note;
            var result = await _useCase.HandleAsync(command);

            if (!result.IsSuccess)
            {
                return(BadRequest(result.Error));
            }

            return(Ok());
        }
Пример #2
0
		public async Task<IActionResult> UpdateAsync(int id, [FromBody] StudentUpdate.Command command)
		{
			var result = new Result<Exception, Unit>();
			IList<ValidationFailure> errors = new List<ValidationFailure>();

			command.Id = id;
			command.IpAddress = GetRemoteIpAddressIPv4();
			command.UserId = UserId;
			command.Email = Email;
			command.UserName = UserName;

			if (command.Validate().IsValid)
			{
				result = await _mediator.Send(command);
			}
			else
			{
				errors = command.Validate().Errors;
			}

			return command.Validate().IsValid ? CustomResponse(result) : CustomResponse(errors);
		}
        public async Task <IActionResult> Update(StudentUpdate.Command command)
        {
            await _useCase.HandleAsync(command);

            return(Ok());
        }