public HttpResponseMessage PostRegistration(PostRegistrationRequest model) { IdentityUser newUserRegistration; if (!ModelState.IsValid) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState)); } // When model is valid, CreateUser will post email and pw to database try { newUserRegistration = UserService.CreateUser(model.Email, model.Password, model.Username); CreateUserProfileJsonData NewUserProfile = new CreateUserProfileJsonData(); NewUserProfile.userName = model.Username; _userProfileService.CreateProfile(newUserRegistration.Id, NewUserProfile); } catch (IdentityResultException) // Display error code and message if user was not created { var ExceptionError = new ErrorResponse("Failed to register new user. (server side)"); return(Request.CreateResponse(HttpStatusCode.BadRequest, ExceptionError)); } // Insert new user's id into token table and generate new token string UserId = newUserRegistration.Id; Guid NewToken = _IUserTokenService.Insert(UserId); // Pass new user's email and token into emailservice for activation link try { string NewUserEmail = newUserRegistration.Email; UserEmailService.SendProfileEmail(NewToken, NewUserEmail); } catch (NotImplementedException) { var ExceptionError = new ErrorResponse("Failed to send activation email to new user"); return(Request.CreateResponse(HttpStatusCode.BadRequest, ExceptionError)); } SystemEventService.AddSystemEvent(new AddSystemEventModel { ActorUserId = UserId, ActorType = ActorType.User, EventType = SystemEventType.UserRegistration }); return(Request.CreateResponse(HttpStatusCode.OK, model)); }
public WriteEventService( IRepository genericRepo, DaoRepository daoRepo, AppConf appConf, MetricsService metricsEvents, SystemEventService notificationEvents) : base(genericRepo, daoRepo, appConf) { _metricsEvents = metricsEvents; _notificationEvents = notificationEvents; daoRepo.AddType <ExternalEventSubscriptionDescriptor>(); }
public RootViewModel(IViewModelFactory viewModelFactory, DialogManager dialogManager, SettingsService settingsService, UpdateService updateService, GammaService gammaService, HotKeyService hotKeyService, RegistryService registryService, ExternalApplicationService externalApplicationService, SystemEventService systemEventService) { _viewModelFactory = viewModelFactory; _dialogManager = dialogManager; _settingsService = settingsService; _updateService = updateService; _gammaService = gammaService; _hotKeyService = hotKeyService; _registryService = registryService; _externalApplicationService = externalApplicationService; _systemEventService = systemEventService; // Title DisplayName = $"{App.Name} v{App.VersionString}"; // Cancel 'disable temporarily' when switched on this.Bind(o => o.IsEnabled, (sender, args) => { if (IsEnabled) { _enableAfterDelayTimer.Stop(); } }); // Initialize timers _updateConfigurationTimer = new AutoResetTimer(UpdateConfiguration); _updateInstantTimer = new AutoResetTimer(UpdateInstant); _updateIsPausedTimer = new AutoResetTimer(UpdateIsPaused); _checkForUpdatesTimer = new AutoResetTimer(async() => await _updateService.CheckPrepareUpdateAsync()); _pollingTimer = new AutoResetTimer(PollGamma); _enableAfterDelayTimer = new ManualResetTimer(Enable); // Reset gamma when power settings change _systemEventService.DisplayStateChanged += (sender, args) => InvalidateGamma(); SystemEvents.DisplaySettingsChanging += (sender, args) => InvalidateGamma(); SystemEvents.DisplaySettingsChanged += (sender, args) => InvalidateGamma(); }
public HttpResponseMessage InsertVote(InsertVoteRequest model) { if (!ModelState.IsValid) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState)); } //get current logged-in user model.VoterId = UserService.GetCurrentUserId(); //insert new row into dbo.PointScore, this creates a log for each vote casted VoteService.VoteInsert(model); //updates overall point score for each username _userProfileService.UpdateUserPointScore(model.UserName, model.NetVote); //updates the review's individual point score if (model.isMedia) { _RatingService.UpdateReviewPointScoreForMedia(model.ContentId, model.NetVote); } else { _RatingService.UpdateReviewPointScore(model.ContentId, model.NetVote); } SystemEventService.AddSystemEvent(new AddSystemEventModel { ActorUserId = model.VoterId, ActorType = ActorType.User, EventType = SystemEventType.UserVote, TargetId = model.ContentId, TargetType = TargetType.Review }); return(Request.CreateResponse(HttpStatusCode.OK, model)); }
public FollowersService(SystemEventService SystemEventService) { _SystemEventService = SystemEventService; }
public BlogsManageService(SystemEventService SystemEventService) { _SystemEventService = SystemEventService; }