public async Task AddMemberAsync(NewMemberDto newMember)
        {
            var json = JsonConvert.SerializeObject(newMember, Formatting.Indented, new JsonSerializerSettings
            {
                NullValueHandling = NullValueHandling.Ignore,
            });

            var newMemberJson = new StringContent(json, Encoding.UTF8, "application/json");

            var createUrl = $"/lists/{_mailchimpConfiguration.AudienceId}/members";

            using var httpResponse = await _httpClient.PostAsync(createUrl, newMemberJson);
        }
Esempio n. 2
0
        public async Task <ActionResult <NewMemberDto> > PostMember(NewMemberDto memberDto)
        {
            Member member = new Member();

            member.Name     = memberDto.Name;
            member.Email    = memberDto.Email;
            member.Password = memberDto.Password;

            foreach (Top top in _context.Tops)
            {
                top.Members.Add(member);
            }

            _context.Members.Add(member);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetMember", new { id = member.Id }, member));
        }