public async Task <IActionResult> Import(IFormFile file) { if (file == null || file.Length == 0) { return(Content("File is not selected!")); } using (var reader = new StreamReader(file.OpenReadStream(), System.Text.Encoding.UTF8)) { var text = await reader.ReadToEndAsync(); var userId = Guid.Parse(User.FindFirst(ClaimTypes.NameIdentifier).Value); var successful = await appointmentsAPI.ImportAsync(userId, text); if (!successful) { return(BadRequest("Could not add item.")); } return(RedirectToAction("Index")); } }
public async Task <bool> ImportAsync(Guid userId, string text) => await client.ImportAsync(userId, text);