public static Member Create(ProfilesDto dto) { var member = new Member { Id = dto.Id, Name = dto.Name, Url = dto.Url, Searchable = RemoveDiacritics(dto.Name) }; string thumbnail; if (!dto.Picture.TryGetValue("thumb_link", out thumbnail)) { thumbnail = @"http://img2.meetupstatic.com/img/2982428616572973604/noPhoto_80.gif"; } member.Picture = thumbnail; member.Membership = Membership.Create(dto.MembershipDues); return(member); }
public IHttpActionResult CreateProfile(string id, ProfilesDto profileDto) { if (!ModelState.IsValid) { return(BadRequest()); } var profileInDb = _context.Profiles.SingleOrDefault(c => c.UserId == id); if (profileInDb == null) { var profile = Mapper.Map <ProfilesDto, Profiles>(profileDto); _context.Profiles.Add(profile); profileDto.Id = profile.Id; } else { Mapper.Map <ProfilesDto, Profiles>(profileDto, profileInDb); } _context.SaveChanges(); return(Ok()); }