Ejemplo n.º 1
0
        public void InterestedPerson_ShouldBeInvalid()
        {
            var interestedPerson = new InterestedPerson {
            };

            var errors = ValidateModel(interestedPerson);

            Assert.IsTrue(errors.Any());
        }
Ejemplo n.º 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());
        }
Ejemplo n.º 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));
            }
        }
Ejemplo n.º 4
0
 public async Task AddInterestedPerson(InterestedPerson interestedPerson)
 {
     _context.Add(interestedPerson);
     await _context.SaveChangesAsync();
 }