예제 #1
0
 public IActionResult Post([FromBody] Event @event)
 {
     try
     {
         if (@event == null)
         {
             return(StatusCode(400, StatusCodes.ReturnStatusObject("No items have been provided.")));
         }
         var result = _eventRepository.Add(@event);
         if (result)
         {
             _logger.LogInformation("Event Successfully Added");
             return(StatusCode(200, StatusCodes.ReturnStatusObject("Successfully Added.")));
         }
         else
         {
             _logger.LogError("Event has Failed to Add. Event - {0}", @event);
             return(StatusCode(400, StatusCodes.ReturnStatusObject("Event failed to add.")));
         }
     }
     catch (Exception e)
     {
         _logger.LogError("Error Event failed to add . Error - {0} , Data - {1}", e.Message, @event);
         return(StatusCode(400, StatusCodes.ReturnStatusObject("Error Event Failed to Add.")));
     }
 }
예제 #2
0
        protected void ListenTo <TSender, TArgs>(IEvent <TSender, TArgs> eventObj, Action <TSender, TArgs> handler)
        {
            /*
             * // wrap it in a listener that will only forward on the event
             * // if the control's screen is active. prevents (for example,
             * // updating the inventory panel, which overwrites the modal
             * // popup, when buying something in a store).
             * Action<TSender, TArgs> activeScreenHandler = (sender, args) =>
             *  {
             *      if (Screen.IsCurrent) handler(sender, args);
             *  };
             *
             * // listen to it
             * eventObj.Add(activeScreenHandler);
             *
             * // and keep track of it to unregister later
             * mEndCallbacks.Add(() => eventObj.Remove(activeScreenHandler));
             */

            // listen to it
            eventObj.Add(handler);

            // and keep track of it to unregister later
            mEndCallbacks.Add(() => eventObj.Remove(handler));
        }
예제 #3
0
        public ActionResult Post(Event Model)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(BadRequest("Data can not be saved"));
                }

                if (EventRepository.AlreadyExists(Model.Title, Model.UserId, Model.Date))
                {
                    return(BadRequest("Record already exists"));
                }

                string Message;
                if (!EventRepository.ValidateInput(Model, out Message))
                {
                    return(BadRequest(Message));
                }

                User User = UserRepository.Get(Model.UserId);
                if (User == null)
                {
                    return(BadRequest("Invalid CreatedBy. User id does not exists."));
                }

                EventRepository.Add(Model);
                EventRepository.Save();

                return(Ok("Record Saved"));
            }
            catch (Exception) { return(BadRequest("Record can not be saved")); }
        }
예제 #4
0
        public Subscription(string objectId, string eventName, IHostAddress clientHostAddress,
                            IOutputChannel outputChannel, IEvent @event)
        {
            _outputChannel    = outputChannel;
            _event            = @event;
            ObjectId          = objectId;
            ClientHostAddress = clientHostAddress;

            _event.Add(this);
        }
 public ViewResult Create(Event _event)
 {
     if (ModelState.IsValid)
     {
         _ievent.Add(_event);
         ViewBag.ValidationMessage = null;
     }
     else
     {
         ViewBag.ValidationMessage = "Validation not Passed.";
     }
     return(View("Create"));
 }
 protected override void Context()
 {
     base.Context();
     _event = new Event().WithName("Sigi Event")
              .WithParentContainer(_root)
              .WithFormula(new ExplicitFormula().WithFormulaString("Time>0"))
              .WithId("1");
     _event.Formula.AddObjectPath(_objectPathFactory.CreateTimePath(A.Fake <IDimension>()));
     _changedEntity = new Parameter().WithName("ChangeMe")
                      .WithParentContainer(_root)
                      .WithFormula(new ExplicitFormula().WithFormulaString("1"))
                      .WithRHS(null);
     _altFormula = new ExplicitFormula().WithFormulaString("2").WithName("alternative Formula");
     _assignment = new EventAssignment {
         ObjectPath = _objectPathFactory.CreateAbsoluteObjectPath(_changedEntity), Formula = _altFormula
     };
     _event.Add(_assignment);
     _assignment.ResolveChangedEntity();
 }
예제 #7
0
 public async Task Post([FromBody] Event t)
 {
     await _ievent.Add(t);
 }