Beispiel #1
0
        public ProfessionalDto CreateProfessional(ProfessionalDto professional)
        {
            if (professional == null)
            {
                RaiseNotification(nameof(professional));
            }

            if (Notification.HasNotification())
            {
                return(new ProfessionalDto());
            }

            var professionalBuilder = new ProfessionalBuilder(Notification)
                                      .WithProfessionalId(professional.ProfessionalId)
                                      .WithCode(professional.Code)
                                      .WithName(professional.Name)
                                      .WithPhone(professional.Phone)
                                      .WithEmail(professional.Email)
                                      .WithAddress(professional.Address)
                                      .WithSpecialties(professional.Specialties.Select(s => new SpecialtyBuilder(Notification).WithId(s.Id).WithDescription(s.Description).Build()).ToList());

            var id = _service.CreateProfessional(professionalBuilder);

            professional.ProfessionalId = id.SecundaryKey;
            professional.Code           = id.PrimaryKey;

            return(professional);
        }
Beispiel #2
0
        public void Professional_Service_Insert_Valid_Professional()
        {
            // Arrange
            var professionalBuilder = new ProfessionalBuilder(LocalNotification)
                                      .WithName("João da Silva")
                                      .WithPhone("15398264438")
                                      .WithEmail("*****@*****.**")
                                      .WithAddress(new Address("Rua do comercio 2", "1233", "APT 1234", new ZipCode("22888888")));

            // Act
            var responseBase = _profissionalService.CreateProfessional(professionalBuilder);

            // Assert
            Assert.False(LocalNotification.HasNotification());
            Assert.NotEqual(responseBase.PrimaryKey, Guid.Empty);
            Assert.NotEqual(responseBase.SecundaryKey, 0);
        }
Beispiel #3
0
 public IHttpActionResult Post(Professional professional)
 {
     if (ModelState.IsValid)
     {
         try
         {
             return(Ok(_professionalService.CreateProfessional(professional)));
         }
         catch (Exception ex)
         {
             Console.WriteLine(ex.StackTrace);
             return(StatusCode(HttpStatusCode.Forbidden));
         }
     }
     else
     {
         return(BadRequest("All fields are required...Try Again!"));
     }
 }