private Guid Insert(Event sEvent)
        {
            List <AffinityDTO> affinities = new List <AffinityDTO>();

            foreach (var affinity in sEvent.Affinities)
            {
                AffinityDTO affinityDTO = new AffinityDTO()
                {
                    AffinityId = affinity.AffinityId,
                    Name       = affinity.Name
                };
                affinities.Add(affinityDTO);
            }

            EventDTO eventDto = new EventDTO()
            {
                EventId     = sEvent.EventId,
                Title       = sEvent.Title,
                Description = sEvent.Description,
                Date        = sEvent.Date,
                Affinities  = affinities,
                Address     = new AddressDTO()
                {
                    CEP          = sEvent.Address.CEP,
                    Avenue       = sEvent.Address.Avenue,
                    Number       = sEvent.Address.Number,
                    Neighborhood = sEvent.Address.Neighborhood,
                    City         = sEvent.Address.City,
                    State        = sEvent.Address.State
                }
            };

            return(eventApplication.Insert(eventDto));
        }
Beispiel #2
0
 public static Affinity ToDomain(AffinityDTO affinity)
 {
     return(new Affinity()
     {
         AffinityId = affinity.AffinityId,
         Name = affinity.Name
     });
 }
Beispiel #3
0
        public static List <AffinityDTO> ListToDTO(List <Affinity> list_affinity)
        {
            List <AffinityDTO> affinities = new List <AffinityDTO>();

            foreach (var affinity in list_affinity)
            {
                AffinityDTO affinityDTO = new AffinityDTO()
                {
                    AffinityId = affinity.AffinityId,
                    Name       = affinity.Name
                };

                affinities.Add(affinityDTO);
            }

            return(affinities);
        }
        private Guid Insert(Entity entity)
        {
            List <AffinityDTO> affinities = new List <AffinityDTO>();

            foreach (var affinity in entity.EntityAffinity)
            {
                AffinityDTO affinityDTO = new AffinityDTO()
                {
                    AffinityId = affinity.AffinityId,
                    Name       = affinity.Name
                };
                affinities.Add(affinityDTO);
            }

            EntityDTO entityDTO = new EntityDTO()
            {
                Id                    = entity.Id,
                UserId                = entity.UserId,
                IsApproved            = entity.IsApproved,
                IsVoluntary           = entity.IsVoluntary,
                EntityName            = entity.EntityName,
                EntityDescription     = entity.EntityDescription,
                Email                 = entity.Email,
                Password              = entity.Password,
                EntityInitials        = entity.EntityInitials,
                EntityPhone           = entity.EntityPhone,
                EntityCreationDate    = entity.EntityCreationDate,
                EntityWebSite         = entity.EntityWebSite,
                EntityResponsableName = entity.EntityResponsableName,
                EntitySocialNetwork   = entity.EntitySocialNetwork,
                EntityAffinity        = affinities,
                EntityAddress         = new AddressDTO()
                {
                    CEP          = entity.EntityAddress.CEP,
                    Avenue       = entity.EntityAddress.Avenue,
                    Number       = entity.EntityAddress.Number,
                    Neighborhood = entity.EntityAddress.Neighborhood,
                    City         = entity.EntityAddress.City,
                    State        = entity.EntityAddress.State
                }
            };

            return(entityApplication.Insert(entityDTO));
        }
        private Guid Insert(Voluntary voluntary)
        {
            Console.WriteLine("POST METHOD CONTROLLER");
            //return Guid.NewGuid();
            //executa o mapeamento

            List <AffinityDTO> affinities = new List <AffinityDTO>();

            foreach (var affinity in voluntary.Affinities)
            {
                AffinityDTO affinityDTO = new AffinityDTO()
                {
                    AffinityId = affinity.AffinityId,
                    Name       = affinity.Name
                };
                affinities.Add(affinityDTO);
            }

            VoluntaryDTO voluntaryDTO = new VoluntaryDTO()
            {
                VoluntaryId   = voluntary.VoluntaryId,
                UserId        = voluntary.UserId,
                IsApproved    = voluntary.IsApproved,
                IsVoluntary   = voluntary.IsVoluntary,
                Name          = voluntary.Name,
                Email         = voluntary.Email,
                Phone         = voluntary.Phone,
                Password      = voluntary.Password,
                SocialNetwork = voluntary.SocialNetwork,
                Affinities    = affinities,
                Address       = new AddressDTO()
                {
                    CEP          = voluntary.Address.CEP,
                    Avenue       = voluntary.Address.Avenue,
                    Number       = voluntary.Address.Number,
                    Neighborhood = voluntary.Address.Neighborhood,
                    City         = voluntary.Address.City,
                    State        = voluntary.Address.State
                }
            };

            return(voluntaryApplication.Insert(voluntaryDTO));
        }
Beispiel #6
0
 // GET api/values/5
 public HttpResponseMessage Get(Guid id)
 {
     try
     {
         AffinityDTO affinitiesDTO = Find(id);
         //Neste local faria uma busca na base de dados
         // Se encontrar o voluntario retorno o voluntario, caso contrário retorna código de nao encontrado
         if (affinitiesDTO == null)
         {
             return(Request.CreateResponse(HttpStatusCode.NotFound, "Afinidade não encontrada"));
         }
         else
         {
             return(Request.CreateResponse(HttpStatusCode.OK, affinitiesDTO));
         }
     }
     catch (Exception ex)
     {
         return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex.Message));
     }
 }
Beispiel #7
0
        private Guid Insert(Donation donation)
        {
            Console.WriteLine("POST DONATION INSERT CONTROLLER");

            List <AffinityDTO> affinities = new List <AffinityDTO>();

            foreach (var affinity in donation.Affinities)
            {
                AffinityDTO affinityDTO = new AffinityDTO()
                {
                    AffinityId = affinity.AffinityId,
                    Name       = affinity.Name
                };
                affinities.Add(affinityDTO);
            }

            DonationDTO donationDto = new DonationDTO()
            {
                DonationId   = donation.DonationId,
                UserId       = donation.UserId,
                Title        = donation.Title,
                Description  = donation.Description,
                Quantity     = donation.Quantity,
                TakeDonation = donation.TakeDonation,
                Affinities   = affinities,

                Address = new AddressDTO()
                {
                    AddressId    = donation.Address.AddressId,
                    CEP          = donation.Address.CEP,
                    Avenue       = donation.Address.Avenue,
                    Number       = donation.Address.Number,
                    Neighborhood = donation.Address.Neighborhood,
                    City         = donation.Address.City,
                    State        = donation.Address.State
                }
            };

            return(DonationApplication.Insert(donationDto));
        }
        private void Alter(Voluntary voluntary)
        {
            List <AffinityDTO> affinities = new List <AffinityDTO>();

            foreach (var affinity in voluntary.Affinities)
            {
                AffinityDTO affinityDTO = new AffinityDTO()
                {
                    AffinityId = affinity.AffinityId,
                    Name       = affinity.Name
                };
                affinities.Add(affinityDTO);
            }

            VoluntaryDTO voluntaryDTO = new VoluntaryDTO()
            {
                VoluntaryId   = voluntary.VoluntaryId,
                UserId        = voluntary.UserId,
                IsApproved    = voluntary.IsApproved,
                IsVoluntary   = voluntary.IsVoluntary,
                Name          = voluntary.Name,
                Email         = voluntary.Email,
                Phone         = voluntary.Phone,
                Password      = voluntary.Password,
                SocialNetwork = voluntary.SocialNetwork,
                Affinities    = affinities,
                Address       = new AddressDTO()
                {
                    CEP          = voluntary.Address.CEP,
                    Avenue       = voluntary.Address.Avenue,
                    Number       = voluntary.Address.Number,
                    Neighborhood = voluntary.Address.Neighborhood,
                    City         = voluntary.Address.City,
                    State        = voluntary.Address.State
                }
            };

            voluntaryApplication.Update(voluntaryDTO);
        }