public async Task <IActionResult> AddKanbanAsync(string name) { HttpContext.Session.TryGetValue("Project", out var project); if (project == null) { return(BadRequest()); } var options = new JsonSerializerOptions { WriteIndented = true }; var proj = System.Text.Json.JsonSerializer.Deserialize <ProjectDto>(project, options); var kanban = new KanbanDto() { Name = name, ProjectId = proj.ProjectId }; var dbKanban = _mapper.Map <Kanbans>(kanban); _context.Kanbans.Add(dbKanban); await _context.SaveChangesAsync(); int.TryParse(HttpContext.Request.Query["projectId"].ToString(), out var projid); return(RedirectToAction(nameof(Index), new { projectId = projid })); }
public void CheckKanbansSaving() { Random rand = new Random(); bool exist = false; var task = new KanbanDto() { Name = "example", ProjectId = rand.Next(1, 5) }; if (task is KanbanDto && task != null) { exist = true; } Assert.IsTrue(exist); }