public void ProcessInput(InputAction inputAction) { switch (inputAction) { case InputAction.SlowDown: { Tick += 0.1; Timer.Change(TimeSpan.FromSeconds(Tick), TimeSpan.FromSeconds(Tick)); View.DisplayTimer(Tick); break; } case InputAction.SpeedUp: { Tick = Math.Max(0, Tick - 0.1); Timer.Change(TimeSpan.FromSeconds(Tick), TimeSpan.FromSeconds(Tick)); View.DisplayTimer(Tick); break; } default: { ActionProcessor.ProcessAction(Player, inputAction.ToAction()); break; } } }
public static void Save(Requester requester) { log.DebugFormat("Save requester with id '{0}'", requester.ID); var service = ServiceManager.GetService <RequesterService>(); var dto = new DataConverter <Requester>().Convert <RequesterDTO>(requester); int?requesterId; if (requester.IsNew) { requesterId = service.Create(dto); } else { service.Update(dto); requesterId = dto.ID; DataPortal.Instance.ResetCachedValue(typeof(Requester), requesterId); } var actionProcessor = new ActionProcessor(); requester.ID = requesterId; requester.UserID = requesterId; ActionTypeEnum actionTypeEnum = requester.IsNew ? ActionTypeEnum.Add : ActionTypeEnum.Update; actionProcessor.ProcessAction(actionTypeEnum, requester); }
public static void Save(Request request) { var service = ServiceManager.GetService <RequestService>(); var dto = new DataConverter <Request>().Convert <RequestDTO>(request); dto.SourceType = RequestSourceEnum.External; var actionTypeEnum = request.IsNew ? ActionTypeEnum.Add : ActionTypeEnum.Update; try { if (request.IsNew) { request.ID = service.Save(dto, Requester.Logged.ID, request.IsUrgent); request.RequestID = request.ID; } else { request.LastEditorID = Requester.Logged.ID; service.Update(dto); } var actionProcessor = new ActionProcessor(); actionProcessor.ProcessAction(actionTypeEnum, request); } catch (Exception ex) { log.Debug("Error catched", ex); var error = ex.Message; if (ex.Message.Contains("AccessDeniedException")) { error = "The request was not posted. Access is denied."; } if (ex.Message.Contains("password is invalid")) { error = "The request was not posted. The provided password is invalid."; } ActionProcessor.SetLastAction(error, null, ActionTypeEnum.None); ActionProcessor.IsError = true; } }
public void Requesting_an_action_that_requires_creation_via_the_action_factory_should_succeed() { var kernel = new StandardKernel(); var statePersistence = new TestActionIoC(); kernel.Bind <TestActionIoC>().ToConstant(statePersistence); var requirements = new TestRequirements(kernel); var processor = new ActionProcessor(requirements, Sys); processor.Start(false); var response = processor.ProcessAction(new ActionRequest <IntegerPayload>(nameof(Add), IntegerPayload.New(0))).Result; AwaitAssert(() => { Assert.AreEqual(1, (statePersistence?.LastPayload as IntegerPayload)?.Value); }, TimeSpan.FromSeconds(1)); }
public void Save() { var serviceWse = ServiceManager.GetService <CommentService>(); var commentDto = new DataConverter <Comment>().Convert <CommentDTO>(this); try { bool isNew = !commentDto.ID.HasValue || commentDto.ID.Value <= 0; if (isNew) { serviceWse.Create(commentDto); } else { serviceWse.Update(commentDto); } var actionProcessor = new ActionProcessor(); actionProcessor.ProcessAction(isNew ? ActionTypeEnum.Add : ActionTypeEnum.Update, this); } catch (Exception e) { log.Debug("Error catched", e); if (e.Message.Contains("should not be empty")) { ActionProcessor.LastAction = ("The description of comment should not be empty"); ActionProcessor.IsError = true; } else { throw; } } }