public async Task Post([FromBody] Model.Attributes newAttributes) { if (!isValidInput(newAttributes)) { return; } if (!isValidJsonString(newAttributes.Data.ToString())) { return; } if (!await IsAuthorized(newAttributes.URN)) { return; } // start the database Database.Attributes attributesDb = new Database.Attributes(); // this attribute is already there? string existingAttributes = await attributesDb.GetAttributes(newAttributes.URN); if (existingAttributes != null) { // ops, already there base.Response.StatusCode = (int)HttpStatusCode.Conflict; return; } // save await attributesDb.SaveAttributes(newAttributes); }
public static void Postfix(Database.Attributes __instance) { var frostbiteThreshold = new Attribute("FrostbiteThreshold", false, Attribute.Display.General, false); frostbiteThreshold.SetFormatter(new StandardAttributeFormatter( GameUtil.UnitClass.Temperature, GameUtil.TimeSlice.None)); __instance.Add(frostbiteThreshold); }
public async Task <JsonResult> Get(string urn) { if (!await IsAuthorized(urn)) { return(new JsonResult(new { Error = "Invalid or expired access token" })); } // start the database Database.Attributes attributesDb = new Database.Attributes(); // return the attributes string attributes = await attributesDb.GetAttributes(urn); var res = new { URN = urn, Data = Newtonsoft.Json.JsonConvert.DeserializeObject(attributes) }; return(new JsonResult(res)); }
public async Task Put(string urn, [FromBody] Model.Attributes updatedAttributes) { if (!isValidInput(updatedAttributes)) { return; } if (!isValidJsonString(updatedAttributes.Data.ToString())) { return; } if (!urn.Equals(updatedAttributes.URN)) { base.Response.StatusCode = (int)HttpStatusCode.BadRequest; return; } if (!await IsAuthorized(urn)) { return; } // start the database Database.Attributes attributesDb = new Database.Attributes(); /* * should we check if the attribute is there or not? * if is not there, let's just create it then... * * // this attribute is already there? * Model.Attributes existingAttributes = await attributesDb.GetAttributes(urn); * if (existingAttributes == null) * { * // ops, not there yet... * base.Response.StatusCode = (int)HttpStatusCode.BadRequest; * return; * } */ await attributesDb.SaveAttributes(updatedAttributes); }
public static void Postfix(Database.Attributes __instance) { Klei.AI.Attribute attribute = new Klei.AI.Attribute(HeartAttackMonitor.ATTRIBUTE_ID, false, Klei.AI.Attribute.Display.Details, false, 0f, null, null); attribute.SetFormatter(new ToPercentAttributeFormatter(1, GameUtil.TimeSlice.None)); __instance.Add(attribute); }