public async Task<BooleanResponse> SaveNotificationEvent(EventEntity entity) { var manager = StatWinner.Common.DependencyInjection.DependencyContainer.GetInstance<IEventManagement>(); return await manager.SaveNotificationEvent(entity); }
/// <summary> /// Save Notification Event /// </summary> /// <param name="entity"></param> /// <returns></returns> public async Task<BooleanResponse> SaveNotificationEvent(EventEntity entity) { var response = new BooleanResponse(); try { var dbEntity = EventManagementFactory.ConvertToEventDbEntity(entity); ApplicationUser appUser = null; if (HttpContext.Current.User != null) { appUser = await UserManager.FindByNameAsync(HttpContext.Current.User.Identity.Name); } if (dbEntity.Id == ObjectId.Empty) { if (appUser != null) { dbEntity.CreatedBy = new EventUserDbEntity() { UserId = appUser.Id.ToString(), EmailAddress = appUser.Email, FullName = String.Format("{0} {1}", appUser.FirstName, appUser.LastName) }; } dbEntity.CreatedDate = DateTime.Now; } if (appUser != null) { dbEntity.ModifiedBy = new EventUserDbEntity() { UserId = appUser.Id.ToString(), EmailAddress = appUser.Email, FullName = String.Format("{0} {1}", appUser.FirstName, appUser.LastName) }; } dbEntity.ModifiedDate = DateTime.Now; var clnEvents = this.StatWinnerDatabase.GetCollection<EventDbEntity>("NotificationEvents"); if (dbEntity.Id == ObjectId.Empty) { dbEntity.Id = ObjectId.GenerateNewId(); await clnEvents.InsertOneAsync(dbEntity); } else { var updateFilter = Builders<EventDbEntity>.Filter.Eq("_id", dbEntity.Id); await clnEvents.ReplaceOneAsync(updateFilter, dbEntity); } } catch (Exception ex) { response.SetError(ex); } return response; }
public async Task<BooleanResponse> SaveNotificationEvent(EventEntity entity) { var notificationEventManagement = new EventManagement(); var response = await notificationEventManagement.SaveNotificationEvent(entity); return response; }