public async void Developer_Delete_Success()
        {
            string messageDelete = "Registro excluído com sucesso!";
            var    developer     = new Developer()
            {
                CPF  = TestHelper.GetAleatoryCPF(),
                Name = "Josh"
            };

            // Act
            var response = await client.PostAsync(
                BasePath + "add",
                new StringContent(JsonConvert.SerializeObject(developer), Encoding.UTF8)
            {
                Headers = { ContentType = new MediaTypeHeaderValue("application/json") }
            });

            Developer developerResponse = await response.Content.ReadAsAsync <Developer>();

            // Assert1
            Assert.Equal(HttpStatusCode.OK, response.StatusCode);

            var responseDelete = await client.DeleteAsync(BasePath + "delete/?id=" + developer.DeveloperId);

            DeveloperViewModel developerDeleteResponse = await responseDelete.Content.ReadAsAsync <DeveloperViewModel>();

            Assert.Equal(HttpStatusCode.OK, responseDelete.StatusCode);
            Assert.Equal(messageDelete, developerDeleteResponse.Messages.FirstOrDefault());


            Assert.Equal(developer.DeveloperId, developerResponse.DeveloperId);
            // Assert2
            Assert.Equal("application/json; charset=utf-8",
                         response.Content.Headers.ContentType.ToString());
        }
예제 #2
0
        public void UpdateDeveloper(DeveloperViewModel developer)
        {
            using (IDbConnection dbConnection = Connection)
            {
                dbConnection.Open();
                var trans = dbConnection.BeginTransaction();

                try
                {
                    string sql = @"UPDATE Developers SET DeveloperName = @DeveloperName,
                                Email = @Email, GithubUrl = @GithubUrl, JoinedDate = @JoinedDate,
                                Status = @Status, LastModified = @LastModified, LastModifiedBy = @LastModifiedBy
                                WHERE DeveloperId = @DeveloperId";

                    dbConnection.Execute(sql, developer, trans);
                    trans.Commit();
                }
                catch (Exception ex)
                {
                    trans.Rollback();
                    throw new Exception("Something wWrong While Update Developer", ex);
                }
                finally
                {
                    dbConnection.Close();
                }
            }
        }
예제 #3
0
        //[ValidateAntiForgeryToken]
        public ActionResult Edit(DeveloperViewModel model)
        {
            var developer = _developerService.GetDeveloper(model.Id);

            if (developer == null)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                developer.Name        = model.Name;
                developer.Description = model.Description;
                developer.CountryId   = model.CountryId;


                var result = _developerService.UpdateDeveloper(developer);

                model.Id = developer.Id;

                if (result.Succedeed)
                {
                    return(Json(model));
                }

                return(NotFound(result));
            }
            return(PartialView(model));
        }
예제 #4
0
        // GET: Own Projects
        public async Task <IActionResult> ProjectIndex()
        {
            var userId    = this.User.FindFirstValue(ClaimTypes.NameIdentifier);
            var developer = _context.Developers.FirstOrDefault(a => a.UserId == userId);

            if (developer is null)
            {
                return(RedirectToAction("Create"));
            }
            List <Project> projects = _context.Projects.Where(m => m.DeveloperId == developer.Id).ToList();

            foreach (Project project in projects)
            {
                project.Openings = _context.Openings.Where(o => o.ProjectId == project.Id).ToList();
                var developerIds = _context.ProjectMembers.Where(p => p.ProjectId == project.Id)
                                   .Select(p => p.DeveloperId)
                                   .ToList();
                project.DeveloperMembers = _context.Developers
                                           .Where(m => developerIds.Contains(m.Id))
                                           .ToList();
            }
            DeveloperViewModel _developerViewModel = new DeveloperViewModel();

            _developerViewModel.CurrentUser = developer;
            _developerViewModel.AllProjects = projects;
            return(View(_developerViewModel));
            //List<Projects>
        }
        public Response Add(Developer entity)
        {
            var response = new Response();

            try
            {
                var category = _categoryRepository.GetById(entity.CategoryId);

                if (category == null)
                {
                    response.Message = "Invalid Category";
                    return(response);
                }

                var dev = repository.Add(entity);

                var devViewModel = new DeveloperViewModel();
                devViewModel.Id        = dev.Id;
                devViewModel.Firstname = dev.Firstname;
                devViewModel.Lastname  = dev.Lastname;
                devViewModel.Email     = dev.Email;
                devViewModel.Category  = dev.Category.Name;

                response.Status    = true;
                response.Developer = devViewModel;
                return(response);
            }
            catch (Exception ex)
            {
                logger.Error("Namespace:DeveloperRepository || \t Method: Add ||\t Ex.Msg : " + ex.Message);
                return(response);
            }
        }
예제 #6
0
        public async Task <ActionResult <DeveloperViewModel> > Update(Guid id, DeveloperViewModel developer)
        {
            if (id != developer.Id)
            {
                NotifyError("O id informado não é o mesmo que foi informado na query");

                return(CustomResponse(developer));
            }

            if (!ModelState.IsValid)
            {
                return(CustomResponse(ModelState));
            }

            try
            {
                await _developerService.Update(_mapper.Map <Developer>(developer));
            }
            catch (Exception ex)
            {
                return(CustomResponse(ex.Message));
            }

            return(CustomResponse(developer));
        }
 public ProjectMemberViewModel(ProjectMember entity)
 {
     Id        = entity.Id;
     CreatedAt = entity.CreatedAt;
     EntryDate = entity.EntryDate;
     Developer = new DeveloperViewModel(entity.Developer);
 }
예제 #8
0
        public static DeveloperViewModel Convert(Developer developer)
        {
            var developerViewModel = new DeveloperViewModel();

            developerViewModel.DevID = developer.DevID;
            developerViewModel.Email = developer.Email;

            return(developerViewModel);
        }
예제 #9
0
 public static List <DeveloperViewModel> ConvertList(IEnumerable <Developer> developers)
 {
     return(developers.Select(e =>
     {
         var model = new DeveloperViewModel();
         model.DevID = e.DevID;
         model.Email = e.Email;
         return model;
     }).ToList());
 }
예제 #10
0
 public ActionResult Edit(DeveloperViewModel model)
 {
     if (ModelState.IsValid)
     {
         var dev = mapper.Map <Developer>(model);
         devService.Update(dev);
         return(RedirectToAction("Index"));
     }
     return(Edit(model.Id));
 }
예제 #11
0
        public ActionResult Add(DeveloperViewModel item)
        {
            if (ModelState.IsValid)
            {
                var developer = mapper.Map <Developer>(item);

                developerService.AddDeveloper(developer);
                return(RedirectToAction("Index"));
            }
            return(Add());
        }
예제 #12
0
        public ActionResult Create(DeveloperViewModel model)
        {
            if (ModelState.IsValid)
            {
                var dev = mapper.Map <Developer>(model);
                devService.AddDeveloper(dev);

                return(RedirectToAction("Index"));
            }
            return(Create());
        }
예제 #13
0
 public ActionResult <DeveloperViewModel> Put([FromBody] DeveloperViewModel developerViewModel)
 {
     if (ValidarRequisicao())
     {
         return(Ok(mapper.Map <DeveloperViewModel>(developerService.Update(mapper.Map <Developer>(developerViewModel)))));
     }
     else
     {
         var responseError = new DeveloperViewModel();
         responseError.Messages = ObterErroModelInvalida();
         return(BadRequest(responseError));
     }
 }
예제 #14
0
        public async Task <DeveloperViewModel> AddDeveloperAsync(DeveloperViewModel newDevloperViewModel,
                                                                 CancellationToken ct = default(CancellationToken))
        {
            var developer = new Developer
            {
                DevID = Guid.NewGuid().ToString("N"),
                Email = "*****@*****.**"
            };

            developer = await _developerRepository.AddAsync(developer, ct);

            newDevloperViewModel.DevID = developer.DevID;
            return(newDevloperViewModel);
        }
예제 #15
0
        public async Task <DeveloperViewModel> Update(DeveloperViewModel developerViewModel)
        {
            var developer = _mapper.Map <Developer>(developerViewModel);

            _developerValidation.ValidationOnUpdating(developer);

            await _developerRepository.UpdateAsync(developer);

            await _developerRepository.SaveChangesAsync();

            var result = await GetById(developer.Id);

            return(result);
        }
        public async void Developer_Delete_Fail()
        {
            string messageDelete = "Não foi possível excluir o registro";
            var    developer     = new Developer()
            {
                CPF  = "46321030000",
                Name = "Josh"
            };

            var responseDelete = await client.DeleteAsync(BasePath + "delete/?id=" + developer.DeveloperId);

            DeveloperViewModel developerDeleteResponse = await responseDelete.Content.ReadAsAsync <DeveloperViewModel>();

            Assert.Equal(HttpStatusCode.OK, responseDelete.StatusCode);
            Assert.Equal(messageDelete, developerDeleteResponse.Messages.FirstOrDefault());
        }
예제 #17
0
        public ActionResult Edit(int?id)
        {
            if (id == null || id <= 0)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            var developer = developerService.GetByID((int)id);

            if (developer == null)
            {
                return(HttpNotFound());
            }
            var model = new DeveloperViewModel(developer);

            return(View(model));
        }
예제 #18
0
        public ActionResult Delete(int?id, DeveloperViewModel developerViewModel)
        {
            try
            {
                var developer = developerService.GetByID((int)id);

                developerService.Delete(developer);
                developerService.Save();

                return(RedirectToAction("Index"));
            }
            catch
            {
                ModelState.AddModelError("", "Database error!");
                return(View(developerViewModel));
            }
        }
예제 #19
0
        public ActionResult <DeveloperViewModel> Delete(Guid id)
        {
            var result    = developerService.Delete(id);
            var developer = new DeveloperViewModel();

            developer.Messages = new List <string>();
            if (result)
            {
                developer.Messages.Add("Registro excluído com sucesso!");
            }
            else
            {
                developer.Messages.Add("Não foi possível excluir o registro");
            }

            return(Ok(developer));
        }
예제 #20
0
        public async Task <IActionResult> Post([FromBody] DeveloperViewModel input,
                                               CancellationToken ct = default)
        {
            try
            {
                if (input == null)
                {
                    return(BadRequest());
                }

                return(StatusCode(201, await _dfsSupervisor.AddDeveloperAsync(input, ct)));
            }
            catch (Exception ex)
            {
                return(StatusCode(500, ex));
            }
        }
예제 #21
0
        // GET: Developers
        public async Task <IActionResult> Index()
        {
            var userId    = this.User.FindFirstValue(ClaimTypes.NameIdentifier);
            var developer = _context.Developers.FirstOrDefault(a => a.UserId == userId);

            if (developer is null)
            {
                return(RedirectToAction("Create"));
            }
            //DeveloperViewModel _developerViewModel = new DeveloperViewModel();
            //_developerViewModel.CurrentUser = developer;
            //foreach (var eachProject in _context.Projects)
            //{
            //    var projectId = eachProject.Id;
            //    ProjectViewModel _projectViewModel = new ProjectViewModel();
            //    _projectViewModel.Project = eachProject;
            //    _projectViewModel.Openings = _context.RoleOpenings.Where(m => m.ProjectId == projectId).ToList();
            //    _projectViewModel.DevelopersInProject = _context.Developers.Where(m => _context.ProjectMembers.Where(p => p.ProjectId == projectId).Select(p => p.DeveloperId).ToList().Contains(m.Id)).ToList();
            //    _developerViewModel.Add(_projectViewModel);
            //}

            List <Project> projects = _context.Projects
                                      .Include(l => l.Developer)
                                      .ToList()
                                      .Where(m => m.IsComplete == false)
                                      .ToList()
            ;

            foreach (Project project in projects)
            {
                project.Openings = _context.Openings.Where(o => o.ProjectId == project.Id).ToList();
                var developerIds = _context.ProjectMembers.Where(p => p.ProjectId == project.Id)
                                   .Select(p => p.DeveloperId)
                                   .ToList();
                project.DeveloperMembers = _context.Developers
                                           .Where(m => developerIds.Contains(m.Id))
                                           .ToList();
            }
            DeveloperViewModel _developerViewModel = new DeveloperViewModel();

            _developerViewModel.CurrentUser = developer;
            _developerViewModel.AllProjects = projects;
            return(View(_developerViewModel));
            //List<Projects>
        }
예제 #22
0
        public ActionResult GetDeveloperDetails(int?id)
        {
            Developer          developer;
            DeveloperViewModel model;

            using (var ctx = new EfDbContext())
            {
                developer = ctx.Developers.FirstOrDefault(x => x.DeveloperId == id);
                model     = new DeveloperViewModel()
                {
                    DeveloperId = id.Value,
                    FirstName   = developer.Account.FirstName,
                    LastName    = developer.Account.LastName
                };
            }

            return(PartialView("_reporerPartial", model));
        }
예제 #23
0
        public DeveloperController(IDeveloperRepo repo, IOptions <CloudinarySettings> cloudinaryConfig)
        {
            _repo             = repo;
            _cloudinaryConfig = cloudinaryConfig;

            Account acc = new Account(
                _cloudinaryConfig.Value.CloudName,
                _cloudinaryConfig.Value.ApiKey,
                _cloudinaryConfig.Value.ApiSecret
                );

            _cloudinary = new Cloudinary(acc);

            DevViewModel = new DeveloperViewModel()
            {
                Developer     = new Developer(),
                DeveloperList = _repo.GetDevelopersSync()
            };
        }
예제 #24
0
        public async Task <ActionResult <DeveloperViewModel> > Add(DeveloperViewModel developer)
        {
            if (!ModelState.IsValid)
            {
                return(CustomResponse(ModelState));
            }

            try
            {
                await _developerService.Add(_mapper.Map <Developer>(developer));
            }
            catch (Exception ex)
            {
                NotifyError(ex.Message);
                return(CustomResponse());
            }

            return(CustomResponse(developer));
        }
        public DeveloperViewModel GetById(object key)
        {
            try
            {
                var dev          = repository.GetById(key);
                var devViewModel = new DeveloperViewModel();
                devViewModel.Id        = dev.Id;
                devViewModel.Firstname = dev.Firstname;
                devViewModel.Lastname  = dev.Lastname;
                devViewModel.Email     = dev.Email;
                devViewModel.Category  = dev.Category.Name;

                return(devViewModel);
            }
            catch (Exception ex)
            {
                logger.Error("Namespace:DeveloperRepository || \t Method: GetById() ||\t Ex.Msg : " + ex.Message);
                return(null);
            }
        }
        public DeveloperViewModel Update(Developer entity)
        {
            try
            {
                var dev = repository.Update(entity);

                var devViewModel = new DeveloperViewModel();
                devViewModel.Id        = dev.Id;
                devViewModel.Firstname = dev.Firstname;
                devViewModel.Lastname  = dev.Lastname;
                devViewModel.Email     = dev.Email;
                devViewModel.Category  = dev.Category.Name;

                return(devViewModel);
            }
            catch (Exception ex)
            {
                logger.Error("Namespace:DeveloperRepository || \t Method: Update ||\t Ex.Msg : " + ex.Message);
                return(new DeveloperViewModel());
            }
        }
예제 #27
0
        public ActionResult Edit(int?id, DeveloperViewModel developerViewModel)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    var developer = developerService.GetByID((int)id);
                    developer.Name = developerViewModel.Name;

                    developerService.Save();

                    return(RedirectToAction("Index"));
                }
                catch
                {
                    ModelState.AddModelError("", "Database error!");
                    return(View(developerViewModel));
                }
            }
            return(View(developerViewModel));
        }
        public IActionResult Profile(int id)
        {
           
            DeveloperModel developer =(DeveloperModel) developerRepository.GetDeveloper(id);

            DeveloperViewModel developerViewModel = new DeveloperViewModel
            {
                DeveloperId = developer.DeveloperId,
                DeveloperName = developer.DeveloperName,
                DeveloperTypeName = developer.DeveloperTypeName,
                ProductsWorked = developer.ProductsWorked,
                ComponentsWorked = developer.ComponentsWorked,
                HardwaresWorked = developer.HardwaresWorked,
                PreviousWorks = developer.PreviousWorks,
                Skills = developer.Skills,
                SolveCount = developer.SolveCount,
                //current_workload=developer.current_workload??0

            };
            return View(developerViewModel);
        }
예제 #29
0
        public ActionResult Edit(int id)
        {
            var developer = _developerService.GetDeveloper(id);

            if (developer == null)
            {
                return(NotFound());
            }

            var model = new DeveloperViewModel()
            {
                Name        = developer.Name,
                Description = developer.Description,
                CountryId   = developer.CountryId
            };


            var books = _countryService.GetCountrys();

            ViewBag.Countries = new SelectList(books, "Id", "Name");
            return(PartialView("Create", model));
        }
        public IActionResult Create(DeveloperViewModel developer)
        {
            string skillset = "";
            List<JsonValue> skills = JsonConvert.DeserializeObject<List<JsonValue>>(developer.Skills);
            foreach (JsonValue skill in skills)
            {
                string processedSkill = TextFormaterTool.DataPreprocess(skill.value);
                if (processedSkill == "" || processedSkill == null) continue;
                skillset += (processedSkill + ",");
            }
           
            DeveloperModel dev = new DeveloperModel
            {
                DeveloperName = developer.DeveloperName.Trim(),
                DeveloperTypeId = developer.DeveloperType,
                Skills= skillset,
                ProductName=developer.Products,
                ComponentName=developer.Components,
                HardwareName=developer.Platforms,
                PreviousWorks = developer.PreviousWorks,
                //current_workload=0

            };
            int developers = (int)developerRepository.AddDeveloper(dev);

            if (developer.DeveloperType==1)
            {
                return RedirectToAction("SiniorExperiencedDevelopers");
            }
            else if (developer.DeveloperType == 2)
            {
                return RedirectToAction("NewExperiencedDevelopers");
            }
            else
            {
                return RedirectToAction("FreshDevelopers");
            }
            
        }