Beispiel #1
0
        public void InterestedPerson_ShouldBeInvalid()
        {
            var interestedPerson = new InterestedPerson {
            };

            var errors = ValidateModel(interestedPerson);

            Assert.IsTrue(errors.Any());
        }
Beispiel #2
0
        public void InterestedPerson_ShouldBeValid()
        {
            var interestedPerson = new InterestedPerson
            {
                Email        = "*****@*****.**",
                FirstName    = "John",
                LastName     = "Doe",
                ActivityType = ActivityType.Basketball
            };

            var errors = ValidateModel(interestedPerson);

            Assert.IsFalse(errors.Any());
        }
Beispiel #3
0
        public async Task <IActionResult> Post([FromBody] InterestedPerson interestedPerson)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    await _interestedPersonRepository.AddInterestedPerson(interestedPerson);

                    return(Ok());
                }
                else
                {
                    _logger.LogError("Error saving employee activity. Model in bad state.");
                    return(BadRequest("Error saving employee activity."));
                }
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, "Exception thrown getting Interested Persons");
                return(BadRequest(ex));
            }
        }
Beispiel #4
0
 public async Task AddInterestedPerson(InterestedPerson interestedPerson)
 {
     _context.Add(interestedPerson);
     await _context.SaveChangesAsync();
 }