public async Task UpdatePlacementDescription_returns_true_on_updated()
        {
            var descriptionToUpdate = new UpdatePlacementDescriptionDTO
            {
                Id              = 1,
                KeywordNames    = new [] { "UML" },
                Degree          = Degree.Bachelor,
                MinSalary       = 10,
                MinWorkingHours = 1,
                MaxWorkingHours = 100,
                Agreement       = true,
                Location        = "Nørreport",
                LastApplyDate   = new DateTime(2020, 12, 10),
                Email           = "*****@*****.**",
                Thumbnail       = new Uri("https://starwarsblog.starwars.com/wp-content/uploads/2020/04/best-friend-in-galaxy-chewbacca_TALL.jpg"),
                Title           = "UML Tester",
                Description     = "You should be able to do UML diagrams correctly",
                CompanyName     = "Spotify"
            };

            var actual = await repository.UpdatePlacementDescriptionAsync(descriptionToUpdate);

            Assert.True(actual);

            var updated = await Context.PlacementDescriptions.FindAsync(descriptionToUpdate.Id);

            Assert.Equal(descriptionToUpdate.KeywordNames, updated.Keywords.Select(k => k.Keyword.Name).ToList());
            Assert.Equal(descriptionToUpdate.CompanyName, updated.Company.Name);
        }
Example #2
0
        public async Task <ActionResult <bool> > Update([FromBody] UpdatePlacementDescriptionDTO description, bool isTest = false)
        {
            try
            {
                var isUpdated = await repository.UpdatePlacementDescriptionAsync(description);

                return(Ok(isUpdated));
            }
            catch (ArgumentException e)
            {
                Util.LogError(e, isTest);
                return(StatusCode(StatusCodes.Status404NotFound));
            }
            catch (Exception e)
            {
                Util.LogError(e, isTest);
                return(StatusCode(StatusCodes.Status500InternalServerError));
            }
        }