public ViewResult Register(int cinemaId = 0) { RegisterEventModel model = new RegisterEventModel(); model.CinemaId = cinemaId; return(View("RegisterEvent", model)); }
public ActionResult Register([FromBody] RegisterEventModel model) { var evt = _mapper.Map <RegisterEventModel, Event>(model); _eventService.Create(evt); return(Ok()); }
public ActionResult Register(RegisterEventModel model) { repository.AddMovie(model.Movie); Event cinemaEvent = new Event(); cinemaEvent.Author = repository.GetUserById(User.Identity.GetUserId()).UserName; cinemaEvent.Cinema = repository.GetCinemaById(model.CinemaId); cinemaEvent.Movie = model.Movie; repository.AddEvent(cinemaEvent); return(RedirectToAction("ViewEvent", "Event", new { cinemaEvent.Cinema.CinemaId })); }
public bool RegisterEvent(RegisterEventModel model) { var server = Context.Servers.FirstOrDefault(x => x.Guid == model.ServerGuid && x.AuthKey == model.ServerKey); if (server == null) { throw new InvalidOperationException("No server matching guid/key pair"); } Task.Run(() => { Player player = null; if (!String.IsNullOrWhiteSpace(model.PlayerGuid)) { player = Context.Players.FirstOrDefault(x => x.Guid == model.PlayerGuid); if (player == null) { // Create new player player = new Player { Guid = model.PlayerGuid, FirstSeen = DateTime.UtcNow }; Context.Players.Add(player); Context.SaveChanges(); } player.LastSeen = DateTime.UtcNow; player.LastServer = server; if (player.Username != model.PlayerName && !String.IsNullOrWhiteSpace(player.Username) && !String.IsNullOrWhiteSpace(model.PlayerName)) { // new event for namechange Context.Events.Add(Event.NewChangeEvent(player, "namechanged", player.Username, model.PlayerName)); } player.Username = model.PlayerName; if (player.Ip != model.PlayerIp && !String.IsNullOrWhiteSpace(player.Ip) && !String.IsNullOrWhiteSpace(model.PlayerIp)) { // new event for ipchange Context.Events.Add(Event.NewChangeEvent(player, "ipchanged", player.Ip, model.PlayerIp)); } player.Ip = model.PlayerIp; if (!String.IsNullOrWhiteSpace(player.Ip)) { player.LastCountry = Startup.IpDatabase.City(player.Ip).Country.IsoCode; } } var evt = new Event { Player = player, ServerId = server.Id, Type = model.EventType, Submitted = DateTime.UtcNow }; Context.Events.Add(evt); Context.SaveChanges(); if (model.EventData != null) { foreach (var evd in model.EventData.Select(kv => new EventData { EventId = evt.Id, Key = kv.Key, Value = kv.Value })) { Context.EventDatas.Add(evd); } } Context.SaveChanges(); RealtimeDispatcher.Get().Broadcast("event.new", evt); }); return(true); }
public bool RegisterPlayerEvent(RegisterEventModel model) { return(RegisterEvent(model)); }
/// <summary> /// This method will, given a license key, generate a new access token /// that is locked to that particular key and return the Id of that key. /// The scope of the access token is preserved (i.e. all methods that were /// enabled in the access token used to access this method will be copied /// to the new access token) except for the key lock, which is going to be /// changed to the id of the license key. Note, for this method to work, /// the access token used to access this method has to have key lock set /// to -1. All of these details are described in Remarks. /// </summary> /// <param name="token">The access token. Read more at https://app.cryptolens.io/docs/api/v3/Auth </param> /// <param name="parameters">The parameters that the method needs</param> /// <remarks>Note: for more details, please see /// <a href="https://app.cryptolens.io/docs/api/v3/RegisterEvent">https://app.cryptolens.io/docs/api/v3/RegisterEvent</a> <br/> /// </remarks> /// <returns>Returns <see cref="KeyLockResult"/> or null.</returns> public static BasicResult RegisterEvent(string token, RegisterEventModel parameters) { return(HelperMethods.SendRequestToWebAPI3 <KeyLockResult>(parameters, "/ai/registerevent/", token)); }