private async Task CreateDemographicRecord(Guest dto) { var demo = _context.DemographicChanges.FirstOrDefault(d => d.FinderNumber == dto.FinderNumber); if (demo == null) { demo = new DemographicChange() { LookupId = dto.LookupId, FinderNumber = dto.FinderNumber, Name = dto.Name, Email = dto.Email, Phone = dto.Phone, Street = dto.Address, Street2 = dto.Address2, City = dto.City, State = dto.State, Zipcode = dto.Zipcode, Source = Source.RSVP }; } else { demo.Name = dto.Name; demo.Email = dto.Name; demo.Phone = dto.Name; demo.Street = dto.Address; demo.Street2 = dto.Address2; demo.City = dto.City; demo.State = dto.State; demo.Zipcode = dto.Zipcode; } _context.DemographicChanges.AddOrUpdate(demo); await _context.SaveChangesAsync(); }
public async Task <ActionResult> Confirm(RegisterFormViewModel dto) { var @event = _eventService.GetEvent(dto.EventId); if (!ModelState.IsValid) { dto.Template = @event.Template; return(View("Register", dto)); } var guest = await _context.Guests.FirstOrDefaultAsync( e => e.FinderNumber == dto.PromoCode && e.EventId == dto.EventId); var d = Mapper.Map <Guest>(dto); if (guest != d) { var demo = new DemographicChange() { LookupId = dto.LookupId, FinderNumber = dto.PromoCode, Name = dto.Name, Email = dto.Email, Phone = dto.Phone, Street = dto.Address, Street2 = dto.Address2, City = dto.City, State = dto.State, Zipcode = dto.Zipcode, Source = Source.RSVP }; _context.DemographicChanges.AddOrUpdate(demo); _context.SaveChanges(); } Mapper.Map(dto, guest); @event.RegisterGuest(guest); await @event.SendEmail(guest); _context.Events.AddOrUpdate(@event); _context.Guests.AddOrUpdate(guest); _context.SaveChanges(); var model = Mapper.Map <FinishFormViewModel>(guest); var template = @event.Template; model.Template = TemplateHelper.ParseGuestTemplate(guest, template); return(View("Finish", model)); }
public async Task <object> Put(ConstituentViewModel vm) { if (vm.Id == 0) { return(NotFound()); } var c = await _context.Constituents.FindAsync(vm.Id); if (c == null) { return(NotFound()); } //var demoChange = Mapper.Map<DemographicChange>(vm); var demoChange = new DemographicChange { Name = vm.Name, FinderNumber = vm.FinderNumber, LookupId = vm.LookupId, Street = vm.Street, Street2 = vm.Street2, City = vm.City, State = vm.State, Zipcode = vm.Zipcode, Email = vm.Email, Phone = vm.Phone, Source = Source.Tax }; _context.DemographicChanges.Add(demoChange); var constituent = Mapper.Map <Constituent>(vm); _context.Constituents.AddOrUpdate(constituent); _context.SaveChanges(); Mapper.Map(constituent, vm); return(Ok(vm)); }