public IEnumerable <MongoDeveloper> ExtractMongoDevelopers()
        {
            var result = new List <MongoDeveloper>();

            var devs = this.dbContext
                       .Developers
                       .Include("Speciality")
                       .Include("Team")
                       .ToList();

            foreach (var dev in devs)
            {
                var devForAdd = new MongoDeveloper(
                    dev.UserName,
                    dev.FirstName + " " + dev.LastName,
                    dev.Age,
                    dev.Speciality.Name,
                    dev.Team.Name,
                    dev.isTeamLeader);
                devForAdd.Id = dev.Id.ToString();

                result.Add(devForAdd);
            }

            return(result);
        }
        public async Task <bool> AddDeveloperToProject(string projectId, MongoDeveloper developer)
        {
            var oldProject = await GetProjectById(projectId);

            developer.Id = Guid.NewGuid().ToString();
            oldProject.Developer.Add(developer);
            var result = await _Projects.ReplaceOneAsync(project => project.Id == projectId, oldProject);

            return(result.IsAcknowledged);
        }
        public async Task <IActionResult> AddDeveloperToProject([FromRoute] string projectId, [FromForm] CreateDeveloperViewModel model)
        {
            if (ModelState.IsValid)
            {
                var developer = new MongoDeveloper
                {
                    Name = model.DeveloperName
                };
                var result = await _mongoProjectService.AddDeveloperToProject(projectId, developer);

                if (result)
                {
                    return(Ok(new { status = 1, message = "Add successfully" }));
                }
                return(BadRequest(new { status = 0, message = "Not Added" }));
            }
            return(BadRequest(new { status = 0, message = "Not Valid" }));
        }