private void CheckTranslations(LifeEvent source, VmOpenApiFintoItemVersionBase target) { target.Code.Should().Be(source.Code); target.Name.First().Value.Should().Be(source.Label); target.OntologyType.Should().Be(source.OntologyType); target.Uri.Should().Be(source.Uri); }
public async Task <IActionResult> PutLifeEvent(int id, LifeEvent lifeEvent) { if (id != lifeEvent.LifeEventId) { return(BadRequest()); } _context.Entry(lifeEvent).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!LifeEventExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <ActionResult <LifeEvent> > PostLifeEvent(LifeEvent lifeEvent) { _context.lifeEvent.Add(lifeEvent); await _context.SaveChangesAsync(); return(CreatedAtAction("GetLifeEvent", new { id = lifeEvent.LifeEventId }, lifeEvent)); }
/// <summary>Snippet for GetLifeEvent</summary> /// <remarks> /// This snippet has been automatically generated for illustrative purposes only. /// It may require modifications to work in your environment. /// </remarks> public void GetLifeEventResourceNames() { // Create client LifeEventServiceClient lifeEventServiceClient = LifeEventServiceClient.Create(); // Initialize request argument(s) LifeEventName resourceName = LifeEventName.FromCustomerLifeEvent("[CUSTOMER_ID]", "[LIFE_EVENT_ID]"); // Make the request LifeEvent response = lifeEventServiceClient.GetLifeEvent(resourceName); }
/// <summary> /// Trigger lives decrease event function. /// </summary> /// <param name="clip"></param> public static void TriggerAdjustLifeEvent(int damage) { LifeEvent thisEvent = null; if (instance.livesEventDictionary.TryGetValue(LIFEADJUSTEVENT, out thisEvent)) { thisEvent.Invoke(damage); } }
/// <summary> /// удаление события /// </summary> /// <param name="item"></param> public void Delete(int id) { LifeEvent LifeEvent = db.LifeEvents.Find(id); if (LifeEvent != null) { db.LifeEvents.Remove(LifeEvent); } }
/// <summary>Snippet for GetLifeEvent</summary> /// <remarks> /// This snippet has been automatically generated for illustrative purposes only. /// It may require modifications to work in your environment. /// </remarks> public void GetLifeEvent() { // Create client LifeEventServiceClient lifeEventServiceClient = LifeEventServiceClient.Create(); // Initialize request argument(s) string resourceName = "customers/[CUSTOMER_ID]/lifeEvents/[LIFE_EVENT_ID]"; // Make the request LifeEvent response = lifeEventServiceClient.GetLifeEvent(resourceName); }
/// <summary>Snippet for GetLifeEventAsync</summary> /// <remarks> /// This snippet has been automatically generated for illustrative purposes only. /// It may require modifications to work in your environment. /// </remarks> public async Task GetLifeEventAsync() { // Create client LifeEventServiceClient lifeEventServiceClient = await LifeEventServiceClient.CreateAsync(); // Initialize request argument(s) string resourceName = "customers/[CUSTOMER_ID]/lifeEvents/[LIFE_EVENT_ID]"; // Make the request LifeEvent response = await lifeEventServiceClient.GetLifeEventAsync(resourceName); }
/// <summary>Snippet for GetLifeEventAsync</summary> /// <remarks> /// This snippet has been automatically generated for illustrative purposes only. /// It may require modifications to work in your environment. /// </remarks> public async Task GetLifeEventResourceNamesAsync() { // Create client LifeEventServiceClient lifeEventServiceClient = await LifeEventServiceClient.CreateAsync(); // Initialize request argument(s) LifeEventName resourceName = LifeEventName.FromCustomerLifeEvent("[CUSTOMER_ID]", "[LIFE_EVENT_ID]"); // Make the request LifeEvent response = await lifeEventServiceClient.GetLifeEventAsync(resourceName); }
/// <summary> /// Remove lives decrease listener function. /// </summary> /// <param name="listener"></param> public static void RemoveAdjustLifeListener(UnityAction <int> listener) { if (eventManager == null) { return; } LifeEvent thisEvent = null; if (instance.livesEventDictionary.TryGetValue(LIFEADJUSTEVENT, out thisEvent)) { thisEvent.RemoveListener(listener); } }
/// <summary>Snippet for GetLifeEventAsync</summary> public async Task GetLifeEventResourceNamesAsync() { // Snippet: GetLifeEventAsync(LifeEventName, CallSettings) // Additional: GetLifeEventAsync(LifeEventName, CancellationToken) // Create client LifeEventServiceClient lifeEventServiceClient = await LifeEventServiceClient.CreateAsync(); // Initialize request argument(s) LifeEventName resourceName = LifeEventName.FromCustomerLifeEvent("[CUSTOMER_ID]", "[LIFE_EVENT_ID]"); // Make the request LifeEvent response = await lifeEventServiceClient.GetLifeEventAsync(resourceName); // End snippet }
/// <summary>Snippet for GetLifeEvent</summary> public void GetLifeEventRequestObject() { // Snippet: GetLifeEvent(GetLifeEventRequest, CallSettings) // Create client LifeEventServiceClient lifeEventServiceClient = LifeEventServiceClient.Create(); // Initialize request argument(s) GetLifeEventRequest request = new GetLifeEventRequest { ResourceNameAsLifeEventName = LifeEventName.FromCustomerLifeEvent("[CUSTOMER_ID]", "[LIFE_EVENT_ID]"), }; // Make the request LifeEvent response = lifeEventServiceClient.GetLifeEvent(request); // End snippet }
/// <summary>Snippet for GetLifeEventAsync</summary> public async Task GetLifeEventAsync() { // Snippet: GetLifeEventAsync(string, CallSettings) // Additional: GetLifeEventAsync(string, CancellationToken) // Create client LifeEventServiceClient lifeEventServiceClient = await LifeEventServiceClient.CreateAsync(); // Initialize request argument(s) string resourceName = "customers/[CUSTOMER_ID]/lifeEvents/[LIFE_EVENT_ID]"; // Make the request LifeEvent response = await lifeEventServiceClient.GetLifeEventAsync(resourceName); // End snippet }
private void SpawnEvents() { List <LifeEvent> eventsToSpawn = new List <LifeEvent>(); List <LifeEvent> eventsToDisable = new List <LifeEvent>(LifeEvents); for (int i = 0; i < eventCount && eventsToDisable.Count > 0; i++) { LifeEvent randEvent = eventsToDisable[Random.Range(0, eventsToDisable.Count)]; eventsToSpawn.Add(randEvent); eventsToDisable.Remove(randEvent); } eventsToSpawn.ForEach(e => e.gameObject.SetActive(true)); eventsToDisable.ForEach(e => e.gameObject.SetActive(false)); }
/// <summary> /// Add lives decrease listener function. /// </summary> /// <param name="eventName"></param> /// <param name="listener"></param> public static void AddAdjustLifeListener(UnityAction <int> listener) { LifeEvent thisEvent = null; if (instance.livesEventDictionary.TryGetValue(LIFEADJUSTEVENT, out thisEvent)) { thisEvent.AddListener(listener); } else { thisEvent = new LifeEvent(); thisEvent.AddListener(listener); instance.livesEventDictionary.Add(LIFEADJUSTEVENT, thisEvent); } }
public void PopulateAndUseClasses() { // school events SchoolEvent s = new SchoolEvent(); s.EventDate = DateTime.Today; s.EventName = "TestEvent"; s.RoomEventIsIn = "TestRoom"; Assert.AreEqual(DateTime.Today, s.EventDate); Assert.AreEqual("TestEvent", s.EventName); Assert.AreEqual("TestRoom", s.RoomEventIsIn); // work events WorkEvent w = new WorkEvent(); w.EventDate = DateTime.Today; w.EventName = "TestEvent"; w.MeetingTime = 0900; Assert.AreEqual(DateTime.Today, w.EventDate); Assert.AreEqual("TestEvent", w.EventName); Assert.AreEqual(0900, w.MeetingTime); // life events LifeEvent l = new LifeEvent(); l.EventDate = DateTime.Today; l.EventName = "TestEvent"; l.Location = "TestLocation"; Assert.AreEqual(DateTime.Today, l.EventDate); Assert.AreEqual("TestEvent", l.EventName); Assert.AreEqual("TestLocation", l.Location); }
public static void Initialize(TruppContext context) { context.Database.EnsureCreated(); if (context.Employees.Any()) { return; } var employees = new Employee[] { new Employee { FullName = "Ricky Carmichael" }, new Employee { FullName = "Ryan Dungey" } }; foreach (Employee e in employees) { context.Employees.Add(e); } context.SaveChanges(); var lifeEventTypes = new LifeEventType[] { new LifeEventType { Type = "Date of hire" }, new LifeEventType { Type = "Marriage" }, new LifeEventType { Type = "Birth/Adoption" }, new LifeEventType { Type = "Gain of other coverage" }, new LifeEventType { Type = "Loss of other coverage" } }; foreach (LifeEventType let in lifeEventTypes) { context.LifeEventTypes.Add(let); } context.SaveChanges(); var lifeEvents = new LifeEvent[] { new LifeEvent { LifeEventTypeID = lifeEventTypes.Single(let => let.Type == "Date of hire").LifeEventTypeID, EmployeeID = employees.Single(e => e.FullName == "Ricky Carmichael").EmployeeID, EventDate = DateTime.Parse("2008-07-04") }, new LifeEvent { LifeEventTypeID = lifeEventTypes.Single(let => let.Type == "Marriage").LifeEventTypeID, EmployeeID = employees.Single(e => e.FullName == "Ricky Carmichael").EmployeeID, EventDate = DateTime.Parse("2010-04-12") }, new LifeEvent { LifeEventTypeID = lifeEventTypes.Single(let => let.Type == "Gain of other coverage").LifeEventTypeID, EmployeeID = employees.Single(e => e.FullName == "Ricky Carmichael").EmployeeID, EventDate = DateTime.Parse("2011-01-01") }, new LifeEvent { LifeEventTypeID = lifeEventTypes.Single(let => let.Type == "Date of hire").LifeEventTypeID, EmployeeID = employees.Single(e => e.FullName == "Ryan Dungey").EmployeeID, EventDate = DateTime.Parse("2015-08-10") }, new LifeEvent { LifeEventTypeID = lifeEventTypes.Single(let => let.Type == "Birth/Adoption").LifeEventTypeID, EmployeeID = employees.Single(e => e.FullName == "Ryan Dungey").EmployeeID, EventDate = DateTime.Parse("2016-02-15") }, new LifeEvent { LifeEventTypeID = lifeEventTypes.Single(let => let.Type == "Birth/Adoption").LifeEventTypeID, EmployeeID = employees.Single(e => e.FullName == "Ryan Dungey").EmployeeID, EventDate = DateTime.Parse("2017-11-30") }, new LifeEvent { LifeEventTypeID = lifeEventTypes.Single(let => let.Type == "Loss of other coverage").LifeEventTypeID, EmployeeID = employees.Single(e => e.FullName == "Ricky Carmichael").EmployeeID, EventDate = DateTime.Parse("2018-06-05") } }; foreach (LifeEvent le in lifeEvents) { context.Add(le); } context.SaveChanges(); }
private void LifeHasBeenModified(LifeEvent e) { DecrementNLives(e.eLife); }
public static string LoadEvent(string code) { try { string[] lines = code.Split(new char[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries); LifeEvent events = new LifeEvent(); events.Description = ""; events.Tag = ""; if (!lines[0].StartsWith("#")) { throw new Exception("the tag is not defined, at line 1"); } events.Tag = lines[0].Remove(0, 1); if (events.Tag.Trim() == "") { throw new Exception("the tag is full of space, at line 1"); } events.Choices = new List <LifeChoice>(); bool InBlock = false; string InnerText = ""; string DataLine = ""; string ChoiceLine = ""; for (int i = 1; i < lines.Length; i++) { switch (lines[i]) { case ("{"): if (InBlock) { throw new Exception("last arrange is not closed, at line " + (i + 1)); } InBlock = true; break; case ("}"): if (!InBlock) { throw new Exception("not arrange is opened, at line " + (i + 1)); } if (InnerText == "") { throw new Exception("empty arrange, at line " + (i + 1)); } InnerText = InnerText.Remove(InnerText.Length - 1); if (InnerText.Trim() == "") { throw new Exception("empty arrange data, at line " + (i + 1)); } InBlock = false; if (events.Description == "") { events.Description = InnerText; } else { if (DataLine == "") { throw new Exception("empty data changes." + "\n -wrong script:" + DataLine); } LifeChoice lc = new LifeChoice(); if (ChoiceLine == "") { throw new Exception("empty choice name." + "\n -wrong script:" + ChoiceLine); } if (!ChoiceLine.StartsWith("#")) { throw new Exception("the choice name is not defined." + "\n -wrong script:" + ChoiceLine); } lc.Name = ChoiceLine.Remove(0, 1); if (lc.Name.Trim() == "") { throw new Exception("the choice name is full of space." + "\n -wrong script:" + ChoiceLine); } string[] s = DataLine.Split(';'); if (s.Length != 4) { throw new Exception("wrong data changes, out of index." + "\n -wrong script:" + DataLine + "(" + s.Length + ")"); } for (int j = 0; j < 3; j++) { if (s[j] == "") { throw new Exception("wrong data changes, no data." + "\n -wrong script:" + s[j]); } try { switch (s[j][0]) { case ('$'): s[j] = s[j].Remove(0, 1); lc.Money = Convert.ToInt64(s[j]); break; case ('@'): s[j] = s[j].Remove(0, 1); lc.Live = Convert.ToInt64(s[j]); break; case ('*'): s[j] = s[j].Remove(0, 1); lc.Spirit = Convert.ToInt64(s[j]); break; default: throw new Exception("unknown data." + "\n -wrong script:" + s[j]); break; } } catch { throw new Exception("wrong choice change data.\n -wrong script:" + s[j]); } } lc.Description = InnerText; events.Choices.Add(lc); } InnerText = ""; ChoiceLine = ""; DataLine = ""; break; default: if (events.Description != "" && ChoiceLine == "") { ChoiceLine = lines[i]; } else { if (events.Description != "" && DataLine == "") { DataLine = lines[i]; } else { InnerText += (lines[i] + "\n"); } } break; } } if (events.Description == "") { throw new Exception("empty description."); } if (events.Choices.Count < 3) { throw new Exception("there must be at least 3 choices."); } Events.Add(events); Log("Loaded life: " + events.Tag + ", " + events.Choices.Count + " choices", ConsoleColor.Green); } catch (Exception e) { Log("Loading life error:" + e.Message, ConsoleColor.Red); return(e.Message); } return(""); }
private void CheckTranslations(string source, LifeEvent target) { target.Uri.Should().Be(source); }
public static void CreateLife() { CurrentEvent = Events[TagList[ran.Next(0, TagList.Count)]]; }
public void SetLifeZeroEvent(LifeEvent lifeEvent) { this.OnLifeZero = lifeEvent; }
public void DecreaseLife() { life--; LifeEvent?.Invoke(life); }
/// <summary> /// создание события /// </summary> /// <param name="item"></param> public void Create(LifeEvent item) => db.LifeEvents.Add(item);
/// <summary> /// обновление события /// </summary> /// <param name="item"></param> public void Update(LifeEvent item) => db.Entry(item).State = EntityState.Modified;