public async Task <int> AddRegistration(EventRegistrationDTO eventRegistration) { if (eventRegistration == null) { throw new ArgumentNullException($"EventRegistration cannot be null"); } var newEntity = mapper.Map <EventRegistration>(eventRegistration); await _ctx.EventRegistrations.AddAsync(newEntity); await _ctx.SaveChangesAsync(); return(newEntity.EventRegistrationId); }
public async Task <EventRegistrationDTO> UpdateRegistration(EventRegistrationDTO entitySrc) { var entityDest = await _ctx.EventRegistrations.FindAsync(entitySrc.EventRegistrationId); if (entityDest != null) { mapper.Map(entitySrc, entityDest); } else { return(null); } await _ctx.SaveChangesAsync(); return(await Task.FromResult(entitySrc)); }
public OperationResultDto SendRegistrationEmail(EventRegistrationDTO registrationInfo) { var mapping = CompanyEventQuizMappingModel.GetOneById(registrationInfo.eventQuizMappingId).Value; if (mapping == null) { return(OperationResultDto.Error("There is no event for this info.")); } var acDomain = CompanyAcServerModel.GetOneById(mapping.CompanyAcDomain.Id).Value; var apiUrl = new Uri(acDomain.AcServer); var proxy = new AdobeConnectProxy(new AdobeConnectProvider(new ConnectionDetails(apiUrl)), Logger, apiUrl); var loginResult = proxy.Login(new UserCredentials(acDomain.Username, acDomain.Password)); if (!loginResult.Success) { throw new InvalidOperationException($"Can't login to AC url {acDomain.AcServer} user {acDomain.Username}"); } var eventInfo = proxy.GetScoInfo(mapping.AcEventScoId); if (!eventInfo.Success) { throw new InvalidOperationException(eventInfo.Status.GetErrorInfo()); } List <string> emailsNotSend = new List <string>(); try { //todo: create model based on success/fail var model = new EventQuizRegistrationModel(Settings) { FirstName = registrationInfo.FirstName, LastName = registrationInfo.LastName, EventName = eventInfo.ScoInfo.Name, EventDesc = eventInfo.ScoInfo.Description, EventScoId = eventInfo.ScoInfo.ScoId, EventStartDate = DateTimeHelper.ConvertToEST(eventInfo.ScoInfo.BeginDate).Value, EventEndDate = DateTimeHelper.ConvertToEST(eventInfo.ScoInfo.EndDate).Value, MailSubject = Emails.RegistrationSubject, MeetingUrl = acDomain.AcServer.TrimEnd('/') + "/" + eventInfo.ScoInfo.SourceSco.UrlPath.TrimStart('/'), Email = registrationInfo.Email }; var attachments = new List <System.Net.Mail.Attachment>(); var e = new Event { //DtStart = new CalDateTime(DateTimeHelper.ConvertToEST(model.EventStartDate).Value), //DtEnd = new CalDateTime(DateTimeHelper.ConvertToEST(model.EventEndDate).Value), DtStart = new CalDateTime(eventInfo.ScoInfo.BeginDate), DtEnd = new CalDateTime(eventInfo.ScoInfo.EndDate), Summary = $"{model.EventName}", Description = model.MeetingUrl, Url = new Uri(model.MeetingUrl) }; var calendar = new Calendar(); calendar.Events.Add(e); var serializer = new CalendarSerializer(new SerializationContext()); var serializedCalendar = serializer.SerializeToString(calendar); Logger.Debug(serializedCalendar); //var ms = new MemoryStream(); //using (var writer = new StreamWriter(ms)) //{ // writer.Write(serializedCalendar); // writer.Flush(); //} //ms.Position = 0; byte[] bytes = new byte[serializedCalendar.Length * sizeof(char)]; Buffer.BlockCopy(serializedCalendar.ToCharArray(), 0, bytes, 0, bytes.Length); var contype = new System.Net.Mime.ContentType("text/calendar"); contype.Parameters.Add("method", "REQUEST"); contype.Parameters.Add("name", "EventInformation.ics"); var calendarItem = new System.Net.Mail.Attachment(new MemoryStream(bytes), contype); calendarItem.TransferEncoding = System.Net.Mime.TransferEncoding.Base64; attachments.Add(calendarItem); var sentSuccessfully = MailModel.SendEmailSync($"{model.FirstName} {model.LastName}", model.Email, Emails.RegistrationSubject, model, Common.AppEmailName, Common.AppEmail, attachments: attachments); if (!sentSuccessfully) { emailsNotSend.Add(model.Email); } } catch (Exception e) { Logger.Error($"[SendRegistrationEmail] error.", e); emailsNotSend.Add(registrationInfo.Email); } return(emailsNotSend.Any() ? OperationResultDto.Error("Not all emails were sent correctly") : OperationResultDto.Success()); }
public async Task <EventRegistrationDTO> UpdateEventRegistration(EventRegistrationDTO registrationSrc) { return(await _attendanceService.UpdateRegistration(registrationSrc)); }
public async Task <int> AddEventRegistration(EventRegistrationDTO e) { return(await _attendanceService.AddRegistration(e)); }
public async Task <EventRegistrationDTO> UpdateRegistration(EventRegistrationDTO eventRegistration) { return(await _attendanceRepository.UpdateRegistration(eventRegistration)); }
public async Task <int> AddRegistration(EventRegistrationDTO eventRegistration) { return(await _attendanceRepository.AddRegistration(eventRegistration)); }