public async Task <IActionResult> Join(int id) { var model = new ActivityJoinViewModel() { Activity = _activityRepository.Get(id) }; return(View(model)); }
public async Task <ActionResult> Join(ActivityJoinViewModel model) { if (ModelState.IsValid) { //await _client.GetRequest<object>($"Activity/{model.IdActivity}/Join"); // Post var user = await _userManager.GetUserAsync(HttpContext.User); var userId = _userRepository.GetIdByIdentity(user.Id); var id = model.IdActivity; if (!ModelState.IsValid) { return(BadRequest(ModelState)); } //model.IdUser = userId; if (Program.UseEventHub) { await _eventHub.SendMessage(new QueueElement <ActivityJoinViewModel> { Type = "ActivityJoin", Data = new ActivityJoinViewModel() { IdActivity = id, IdUser = userId }, }); } else { var queue = new ServiceBusManager(_configuration["ServiceBusConnectionString"], _configuration["ServiceBusQueueName"]); await queue.SendMessage(new QueueElement <ActivityJoinViewModel> { Type = "ActivityJoin", Data = new ActivityJoinViewModel() { IdActivity = id, IdUser = userId }, }); } return(RedirectToAction("Index")); } return(BadRequest(ModelState)); }