public async Task <ActionResult> JoinByUrl(ActivityStringViewModel model) // contains activity id { /* if (!Program.UseShSend) * { * return BadRequest(); * } */ if (ModelState.IsValid) { var user = await _userManager.GetUserAsync(HttpContext.User); var userId = _userRepository.GetIdByIdentity(user.Id); model.IdUser = userId; var client = new ApiRequest($"{model.EndPointUrl}/", userId, ""); var data = await client.PostRequest <Activity>("Join", model); if (data != null) // Placeholder checks { data.IdUser = -data.IdUser; data.Id = 0; var newId = _activityRepository.Insert(data); _activityRepository.AddRunner(newId, userId); } return(RedirectToAction("Index")); } return(BadRequest(ModelState)); }
public async Task <Activity> GetByUrl(int id) // Activity ID { if (!Program.UseShSend || !ModelState.IsValid) { return(null); } if (!_activityRepository.IsRunnerAdded(id, userId)) { _activityRepository.AddRunner(id, userId); // OTHER WORKER } var model = _activityRepository.Get(id); /* * model.IdUser = userId; * var queue = new ServiceBusManager(_configuration["ServiceBusConnectionString"], _configuration["ServiceBusQueueName"]); * await queue.SendMessage(new QueueElement<ActivityCreateViewModel> * { * Type = "ActivityCreate", * Data = model, * }); */ return(model); }