public async Task <IActionResult> CreateUpdatePost(PostUpdateViewModel update) { PostUpdate realupdate = new PostUpdate(); try { if (ModelState.IsValid) { var uploads = Path.Combine(_environment.WebRootPath, "PostImages"); foreach (var file in update.files) { realupdate.image = file.FileName; if (file.Length > 0) { using (var fileStream = new FileStream(Path.Combine(uploads, file.FileName), FileMode.Create)) { await file.CopyToAsync(fileStream); } } } realupdate.postID = update.postID; realupdate.title = update.title; realupdate.description = update.description; string resp = postDB.UpdatePost(realupdate); } } catch (Exception ex) { TempData["msg"] = ex.Message; } return(RedirectToAction("Index", "Home")); }
/// <summary> /// Allows the game to run logic such as updating the world, /// checking for collisions, gathering input, and playing audio. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> protected override void Update(GameTime gameTime) { if (!IsActive) { base.Update(gameTime); PostUpdate?.Invoke(); return; } if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape)) { if (_screens.Count <= 1) { Environment.Exit(0); } else { _screens.Pop(); } } UpdateTopScreenRecursive(gameTime.ElapsedGameTime.TotalSeconds); base.Update(gameTime); PostUpdate?.Invoke(); }
public ActionResult Edit(PostEditModel model) { if (model != null && this.ModelState.IsValid) { var post = this.Data.Posts.GetById(model.Id); var userId = this.User.Identity.GetUserId(); post.Title = model.Title; post.Content = model.Content; post.CategoryId = model.CategoryId; post.IsDeleted = model.IsDeleted; this.Data.Posts.Update(post); this.Data.SaveChanges(); if (model.Reason != null) { var postUpdate = new PostUpdate { AuthorId = userId, PostId = post.Id, Reason = model.Reason }; this.Data.PostUpdates.Add(postUpdate); this.Data.SaveChanges(); } return(this.RedirectToAction("All")); } return(this.View(model)); }
public Response UpdatePost(PostUpdate post) { var result = RunInsertJson(post.images); if (result.valid) { var procedure = "sp_post_update"; using (var conn = new MySqlConnection(_connectionString)) { try { conn.Open(); var param = new DynamicParameters(); param.Add("INid", post.id); param.Add("INname", post.name); param.Add("INcontent", post.content); param.Add("INurl", post.url); var data = conn.QueryFirstOrDefault <Response>(procedure, param, commandType: System.Data.CommandType.StoredProcedure); return(data); } catch (Exception ex) { throw; } } } else { return(null); } }
public IActionResult GoToPost(int id) { PostAndUpdateViewModel realmodel = new PostAndUpdateViewModel(); PostViewModel realpostmodel = new PostViewModel(); PostUpdateViewModel realupdatemodel = new PostUpdateViewModel(); List <Post> DBPosts = postDB.GetPosts(); List <Post> IDPosts = DBPosts.Where(x => x.id == id).ToList(); Post currentmodel = IDPosts[0]; realpostmodel.id = currentmodel.id; realpostmodel.title = currentmodel.title; realpostmodel.description = currentmodel.description; realpostmodel.tag = currentmodel.tag; realpostmodel.image = currentmodel.image; List <PostUpdate> DBUpdatePosts = postDB.GetUpdatePosts(); List <PostUpdate> IDUpdatePosts = DBUpdatePosts.Where(x => x.postID == id).ToList(); PostUpdate currentupdatemodel = DBUpdatePosts[0]; realupdatemodel.id = currentupdatemodel.id; realupdatemodel.postID = currentupdatemodel.postID; realupdatemodel.title = currentupdatemodel.title; realupdatemodel.description = currentupdatemodel.description; realupdatemodel.image = currentupdatemodel.image; List <PostUpdateViewModel> RealUpdateList = new List <PostUpdateViewModel>(); RealUpdateList.Add(realupdatemodel); realmodel.postupdate = IDUpdatePosts; realmodel.post = realpostmodel; return(View("~/Views/Post/ViewPost.cshtml", realmodel)); }
public void SimulateFrame() { // TODO: Not sure about creating hundreds of objects per second. // Doesn't seem to cause high memory usage, but further investigation is needed. PreUpdate.Raise(this, new UpdateEventArgs(_monitor.FrameRate, _monitor.LastFrameTime, UpdateTimeStep)); _unprocessedTime += _monitor.LastFrameTime; _updates = 0; while (_unprocessedTime >= UpdateTimeStep && _updates < MaxSkippedFrames) { OnUpdate.Raise(this, new UpdateEventArgs(_monitor.FrameRate, _monitor.LastFrameTime, UpdateTimeStep)); _simulationEngine.Simulate(); _unprocessedTime -= UpdateTimeStep; _updates++; } PostUpdate.Raise(this, new UpdateEventArgs(_monitor.FrameRate, _monitor.LastFrameTime, UpdateTimeStep)); if (EnableRender) { _renderer.Frame(); _renderer.Render(); } }
public async void UpdatePost(Guid postId, PostUpdate update) { var uriString = _apiConfig.PostsApiUrl + "/api/posts/" + postId; var response = await _apiClient.PutAsync(uriString, update); response.EnsureSuccessStatusCode(); }
/// <inheritdoc /> public void Update(TimeSpan total, TimeSpan elapsed, bool isRunningSlowly) { PreUpdate?.Invoke(this, new UpdateEventArgs(total, elapsed, isRunningSlowly)); InternalUpdate(total, elapsed, isRunningSlowly); PostUpdate?.Invoke(this, new UpdateEventArgs(total, elapsed, isRunningSlowly)); }
public override void OnPostUpdate(float fDeltaTime) { if (Engine.GameFramework.IsInLevelLoad()) { return; } PostUpdate?.Invoke(); }
/// <summary> /// Invokes the Xna PostUpdate event. /// </summary> /// <param name="gameTime"></param> public static void InvokePostUpdate(GameTime gameTime) { var args = new XnaUpdateEventArgs { GameTime = gameTime }; PostUpdate.Invoke(args); }
internal static IEnumerable <T> OnPostUpdate(IEnumerable <T> entities) { if (entities == null || PostUpdate == null) { return(entities); } return(PostUpdate .GetInvocationList() .OfType <EntityProcessor <T> >() .Aggregate(entities, (e, processor) => processor(e))); }
public IActionResult UpdatePost(Guid postId, [FromBody] PostUpdate form) { try { _postsService.UpdatePost(postId, form); } catch (Exception ex) { return(BadRequest(ex.Message)); } return(Ok()); }
public async Task <IActionResult> Put(Guid id, [FromBody] PostUpdate postUpdate) { var post = await _posts.Where(p => p.Id == id).FirstOrDefaultAsync(); if (post != null) { post.Content = postUpdate.Content; } _posts.Update(post); await _context.SaveChangesAsync(); return(Ok()); }
public bool UpdatePost(PostUpdate model) { using (var ctx = new ApplicationDbContext()) { var entity = ctx.Posts.Single(e => e.Id == model.Id); entity.Title = model.Title; entity.Text = model.Text; return(ctx.SaveChanges() == 1); } }
public Post Update(PostUpdate post, int userDisplayId) { var toEdit = context.Posts.SingleOrDefault(p => p.Id == post.Id && p.CreatedById == userDisplayId); if (toEdit != null) { toEdit.Content = post.Content; toEdit.UpdatedOn = DateTime.Now; context.Update(toEdit); context.SaveChanges(); } return(toEdit); }
public IActionResult Update([FromBody] PostUpdate input) { var a = _postAppService.GetById(input.Id); if (a == null) { throw new Exception("Không tồn tại Post để update"); } else { var post = _postAppService.Update(input); return(Ok("Thành công")); } }
public IActionResult UpdatePost([FromBody] PostUpdate post) { if (!Request.Headers.ContainsKey("Authorization")) { return(Unauthorized()); } var data = _alphahomeService.UpdatePost(post); if (data.valid) { return(new JsonResult(data)); } return(BadRequest(data)); }
public IHttpActionResult Put(PostUpdate post) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var service = CreatePostService(); if (!service.UpdatePost(post)) { return(InternalServerError()); } return(Ok()); }
public async Task <Post> UpdatePost(PostUpdate postUpdate) { var post = await _shopDbContext.PostRepository.All .FirstOrDefaultAsync(p => p.PostId == postUpdate.PostId); if (post == null) { throw new EntityNotFoundException( $"Post {postUpdate.PostId} not found! Can't update the post"); } _mapper.Map(postUpdate, post); _shopDbContext.PostRepository.Update(post); await _shopDbContext.SaveAsync(); return(_mapper.Map <Post>(post)); }
public virtual void Update(float deltaTime) { PreUpdate?.Invoke(deltaTime); if (!enabled) { return; } if (IsMouseOver || (!RequireMouseOn && selectedWidgets.Contains(this) && PlayerInput.PrimaryMouseButtonHeld())) { Hovered?.Invoke(); System.Diagnostics.Debug.WriteLine("hovered"); if (RequireMouseOn || PlayerInput.PrimaryMouseButtonDown()) { if ((multiselect && !selectedWidgets.Contains(this)) || selectedWidgets.None()) { selectedWidgets.Add(this); Selected?.Invoke(); } } } else if (selectedWidgets.Contains(this)) { System.Diagnostics.Debug.WriteLine("selectedWidgets.Contains(this) -> remove"); selectedWidgets.Remove(this); Deselected?.Invoke(); } if (IsSelected) { if (PlayerInput.PrimaryMouseButtonDown()) { MouseDown?.Invoke(); } if (PlayerInput.PrimaryMouseButtonHeld()) { MouseHeld?.Invoke(deltaTime); } if (PlayerInput.PrimaryMouseButtonClicked()) { MouseUp?.Invoke(); } } PostUpdate?.Invoke(deltaTime); }
/// <inheritdoc /> public void Update(TimeSpan total, TimeSpan elapsed, bool isRunningSlowly) { PreUpdate?.Invoke(this, new UpdateEventArgs(total, elapsed, isRunningSlowly)); Mouse.Update(total, elapsed, isRunningSlowly); foreach (Dialog dialog in Dialogs) { dialog.Update(total, elapsed, isRunningSlowly); } foreach (Window window in Windows) { window.Update(total, elapsed, isRunningSlowly); } Dialog.IsShownInCurrentLoopIteration = false; PostUpdate?.Invoke(this, new UpdateEventArgs(total, elapsed, isRunningSlowly)); }
public virtual void Update(float deltaTime) { PreUpdate?.Invoke(deltaTime); if (!enabled) { return; } if (IsMouseOver || (!RequireMouseOn && selectedWidgets.Contains(this) && PlayerInput.LeftButtonHeld())) { Hovered?.Invoke(); if (RequireMouseOn || PlayerInput.LeftButtonDown()) { if ((multiselect && !selectedWidgets.Contains(this)) || selectedWidgets.None()) { selectedWidgets.Add(this); Selected?.Invoke(); } } } else if (selectedWidgets.Contains(this)) { selectedWidgets.Remove(this); Deselected?.Invoke(); } if (IsSelected) { if (PlayerInput.LeftButtonDown()) { MouseDown?.Invoke(); } if (PlayerInput.LeftButtonHeld()) { MouseHeld?.Invoke(deltaTime); } if (PlayerInput.LeftButtonClicked()) { MouseUp?.Invoke(); } } PostUpdate?.Invoke(deltaTime); }
/// <inheritdoc /> public void Update(TimeSpan total, TimeSpan elapsed, bool isRunningSlowly) { if (!IsVisible) { return; } PreUpdate?.Invoke(this, new UpdateEventArgs(total, elapsed, isRunningSlowly)); if (!IsLoaded) { Load(); } this.location.X = destination.X; this.location.Y = destination.Y; if (Intersects(Mouse.X, Mouse.Y)) { if (!isMouseIntersectingPrevious) { MouseEnter?.Invoke(this, EventArgs.Empty); } this.isMouseIntersectingPrevious = true; } else { if (isMouseIntersectingPrevious) { MouseLeave?.Invoke(this, EventArgs.Empty); } this.isMouseIntersectingPrevious = false; } InternalUpdate(total, elapsed, isRunningSlowly); PostUpdate?.Invoke(this, new UpdateEventArgs(total, elapsed, isRunningSlowly)); }
/// <inheritdoc /> public void Update(TimeSpan total, TimeSpan elapsed, bool isRunningSlowly) { if (!IsWithinGameWindow(core.Location.X, core.Location.Y)) { return; } lastLocation = core.Location; PreUpdate?.Invoke(this, new UpdateEventArgs(total, elapsed, isRunningSlowly)); if (Left == MouseButtonState.Released && leftPrevious == MouseButtonState.Pressed) { ButtonUp?.Invoke(this, new MouseButtonClickEventArgs(X, Y, MouseButton.Left)); } else if (Middle == MouseButtonState.Released && middlePrevious == MouseButtonState.Pressed) { ButtonUp?.Invoke(this, new MouseButtonClickEventArgs(X, Y, MouseButton.Middle)); } else if (Right == MouseButtonState.Released && rightPrevious == MouseButtonState.Pressed) { ButtonUp?.Invoke(this, new MouseButtonClickEventArgs(X, Y, MouseButton.Right)); } else if (X1 == MouseButtonState.Released && x1Previous == MouseButtonState.Pressed) { ButtonUp?.Invoke(this, new MouseButtonClickEventArgs(X, Y, MouseButton.X1)); } else if (X2 == MouseButtonState.Released && x2Previous == MouseButtonState.Pressed) { ButtonUp?.Invoke(this, new MouseButtonClickEventArgs(X, Y, MouseButton.X2)); } leftPrevious = Left; middlePrevious = Middle; rightPrevious = Right; x1Previous = X1; x2Previous = X2; PostUpdate?.Invoke(this, new UpdateEventArgs(total, elapsed, isRunningSlowly)); }
public void GetTarget_ThrowsError() { #region arrange - given var context = new FakeLocalPluginContext(); #endregion #region act & assert Assert.ThrowsException <System.NullReferenceException>( () => { Entity target = PostUpdate.GetTargetEntity(null); }); Assert.ThrowsException <System.NullReferenceException>( () => { Entity target = PostUpdate.GetTargetEntity(context); }); #endregion }
private void Update() { PreUpdate?.Invoke(this, null); //Blackout. TODO: Cleanup this a bit. Maybe push blank effect frame to keyboard incase it has existing stuff displayed if ((Global.Configuration.time_based_dimming_enabled && Utils.Time.IsCurrentTimeBetween(Global.Configuration.time_based_dimming_start_hour, Global.Configuration.time_based_dimming_start_minute, Global.Configuration.time_based_dimming_end_hour, Global.Configuration.time_based_dimming_end_minute))) { return; } string raw_process_name = Path.GetFileName(processMonitor.ProcessPath); UpdateProcess(); EffectsEngine.EffectFrame newFrame = new EffectsEngine.EffectFrame(); //TODO: Move these IdleEffects to an event //this.UpdateIdleEffects(newFrame); ILightEvent profile = GetCurrentProfile(out bool preview); timerInterval = profile?.Config?.UpdateInterval ?? defaultTimerInterval; if ((profile is Desktop.Desktop && !profile.IsEnabled) || Global.Configuration.excluded_programs.Contains(raw_process_name)) { Global.dev_manager.Shutdown(); Global.effengine.PushFrame(newFrame); return; } else { Global.dev_manager.InitializeOnce(); } if (Global.Configuration.OverlaysInPreview || !preview) { foreach (var underlay in Underlays) { ILightEvent @event = Events[underlay]; if (@event.IsEnabled && (@event.Config.ProcessNames == null || ProcessUtils.AnyProcessExists(@event.Config.ProcessNames))) { @event.UpdateLights(newFrame); } } } //Need to do another check in case Desktop is disabled or the selected preview is disabled if (profile.IsEnabled) { profile.UpdateLights(newFrame); } if (Global.Configuration.OverlaysInPreview || !preview) { foreach (var overlay in Overlays) { ILightEvent @event = Events[overlay]; if (@event.IsEnabled && (@event.Config.ProcessNames == null || ProcessUtils.AnyProcessExists(@event.Config.ProcessNames))) { @event.UpdateLights(newFrame); } } //Add overlays TimedListObject[] overlay_events = overlays.ToArray(); foreach (TimedListObject evnt in overlay_events) { if ((evnt.item as LightEvent).IsEnabled) { (evnt.item as LightEvent).UpdateLights(newFrame); } } UpdateIdleEffects(newFrame); } Global.effengine.PushFrame(newFrame); PostUpdate?.Invoke(this, null); }
private void Update() { PreUpdate?.Invoke(this, null); UpdatedEvents.Clear(); //Blackout. TODO: Cleanup this a bit. Maybe push blank effect frame to keyboard incase it has existing stuff displayed if ((Global.Configuration.time_based_dimming_enabled && Utils.Time.IsCurrentTimeBetween(Global.Configuration.time_based_dimming_start_hour, Global.Configuration.time_based_dimming_start_minute, Global.Configuration.time_based_dimming_end_hour, Global.Configuration.time_based_dimming_end_minute))) { StopUnUpdatedEvents(); return; } string raw_process_name = Path.GetFileName(processMonitor.ProcessPath); UpdateProcess(); EffectsEngine.EffectFrame newFrame = new EffectsEngine.EffectFrame(); //TODO: Move these IdleEffects to an event //this.UpdateIdleEffects(newFrame); ILightEvent profile = GetCurrentProfile(out bool preview); timerInterval = profile?.Config?.UpdateInterval ?? defaultTimerInterval; // If the current foreground process is excluded from Aurora, disable the lighting manager if ((profile is Desktop.Desktop && !profile.IsEnabled) || Global.Configuration.excluded_programs.Contains(raw_process_name)) { StopUnUpdatedEvents(); Global.dev_manager.Shutdown(); Global.effengine.PushFrame(newFrame); return; } else { Global.dev_manager.InitializeOnce(); } if (Global.Configuration.OverlaysInPreview || !preview) { foreach (var underlay in Underlays) { ILightEvent @event = Events[underlay]; if (@event.IsEnabled && (@event.Config.ProcessNames == null || ProcessUtils.AnyProcessExists(@event.Config.ProcessNames))) { UpdateEvent(@event, newFrame); } } } //Need to do another check in case Desktop is disabled or the selected preview is disabled if (profile.IsEnabled) { UpdateEvent(profile, newFrame); } if (Global.Configuration.OverlaysInPreview || !preview) { // Update any overlays registered in the Overlays array. This includes applications with type set to Overlay and things such as skype overlay foreach (var overlay in Overlays) { ILightEvent @event = Events[overlay]; if (@event.IsEnabled && (@event.Config.ProcessNames == null || ProcessUtils.AnyProcessExists(@event.Config.ProcessNames))) { UpdateEvent(@event, newFrame); } } // Update any overlays that are timer-based (e.g. the volume overlay that appears for a few seconds at a time) TimedListObject[] overlay_events = overlays.ToArray(); foreach (TimedListObject evnt in overlay_events) { if ((evnt.item as LightEvent).IsEnabled) { UpdateEvent((evnt.item as LightEvent), newFrame); } } // Update any applications that have overlay layers if that application is open var events = GetOverlayActiveProfiles().ToList(); //Add the Light event that we're previewing to be rendered as an overlay if (preview && Global.Configuration.OverlaysInPreview && !events.Contains(profile)) { events.Add(profile); } foreach (var @event in events) { @event.UpdateOverlayLights(newFrame); } UpdateIdleEffects(newFrame); } Global.effengine.PushFrame(newFrame); StopUnUpdatedEvents(); PostUpdate?.Invoke(this, null); }
private void Update() { PreUpdate?.Invoke(this, null); UpdatedEvents.Clear(); //Blackout. TODO: Cleanup this a bit. Maybe push blank effect frame to keyboard incase it has existing stuff displayed if ((Global.Configuration.time_based_dimming_enabled && Utils.Time.IsCurrentTimeBetween(Global.Configuration.time_based_dimming_start_hour, Global.Configuration.time_based_dimming_start_minute, Global.Configuration.time_based_dimming_end_hour, Global.Configuration.time_based_dimming_end_minute))) { StopUnUpdatedEvents(); return; } string raw_process_name = Path.GetFileName(processMonitor.ProcessPath); UpdateProcess(); EffectsEngine.EffectFrame newFrame = new EffectsEngine.EffectFrame(); //TODO: Move these IdleEffects to an event //this.UpdateIdleEffects(newFrame); ILightEvent profile = GetCurrentProfile(out bool preview); timerInterval = profile?.Config?.UpdateInterval ?? defaultTimerInterval; // If the current foreground process is excluded from Aurora, disable the lighting manager if ((profile is Desktop.Desktop && !profile.IsEnabled) || Global.Configuration.excluded_programs.Contains(raw_process_name)) { StopUnUpdatedEvents(); Global.dev_manager.Shutdown(); Global.effengine.PushFrame(newFrame); return; } else { Global.dev_manager.InitializeOnce(); } //Need to do another check in case Desktop is disabled or the selected preview is disabled if (profile.IsEnabled) { UpdateEvent(profile, newFrame); } // Overlay layers if (!preview || Global.Configuration.OverlaysInPreview) { foreach (var @event in GetOverlayActiveProfiles()) { @event.UpdateOverlayLights(newFrame); } //Add the Light event that we're previewing to be rendered as an overlay (assuming it's not already active) if (preview && Global.Configuration.OverlaysInPreview && !GetOverlayActiveProfiles().Contains(profile)) { profile.UpdateOverlayLights(newFrame); } UpdateIdleEffects(newFrame); } Global.effengine.PushFrame(newFrame); StopUnUpdatedEvents(); PostUpdate?.Invoke(this, null); }
internal void _PostUpdate() => PostUpdate?.Invoke(this);
public async Task UpdatePost([FromBody] PostUpdate postUpdate) { var post = _mapper.Map <Business.Post.PostUpdate>(postUpdate); await _postProvider.UpdatePost(post); }
// Use this for initialization void Start() { postUpdater = gameObject.GetComponent<PostUpdate> (); }