public IActionResult Put([FromBody] DeveloperVM request)
        {
            if (!ModelState.IsValid)
            {
                NotifyModelStateErrors();
                return(Response(request));
            }

            _developerService.Update(request);

            return(Response(request));
        }
        public IActionResult Create(DeveloperVM request)
        {
            if (!ModelState.IsValid)
            {
                return(View(request));
            }
            developerService.Register(request);

            if (IsValidOperation())
            {
                ViewBag.Sucesso = "Developer Registered!";
            }

            return(View(request));
        }
        public IActionResult Edit(DeveloperVM request)
        {
            if (!ModelState.IsValid)
            {
                return(View(request));
            }

            developerService.Update(request);

            if (IsValidOperation())
            {
                ViewBag.Sucesso = "Developer Updated!";
            }

            return(View(request));
        }
Beispiel #4
0
        public void RetriveAllDevelopersByAPI_ShouldReturn_AllMatchDevelopers_InDB()
        {
            PropertyInfo[] pinfo  = (typeof(DeveloperVM)).GetProperties();
            APIClient      client = new APIClient(BaseURL + "Companies", string.Empty, "json", _client);

            client.CallApi();

            string  result    = client.Result.Result;
            JObject resObject = JObject.Parse(result);

            var apiResults = from d in resObject["data"]
                             select d;

            var dbDevelopers = _repository.GetDevelopersAsync().Result.ToList();

            int expected = dbDevelopers.Count();
            int actual   = apiResults.Count();

            Assert.Equal(expected, actual);

            if (apiResults.Any())
            {
                foreach (var item in apiResults)
                {
                    DeveloperVM actualDta   = JsonConvert.DeserializeObject <DeveloperVM>(item.ToString());
                    DeveloperVM expectedDta = dbDevelopers.FirstOrDefault(f => f.ID == actualDta.ID);

                    foreach (var prop in pinfo)
                    {
                        var actualVal   = prop.GetValue(actualDta);
                        var expectedVal = prop.GetValue(expectedDta);

                        Assert.Equal(expectedVal, actualVal);
                    }
                }
            }
        }
        public void Update(DeveloperVM request)
        {
            var updateCommand = mapper.Map <UpdateDeveloperCommand>(request);

            bus.SendCommand(updateCommand);
        }
        public void Register(DeveloperVM developerVM)
        {
            var registerCommand = mapper.Map <RegisterNewDeveloperCommand>(developerVM);

            bus.SendCommand(registerCommand);
        }