public bool AddMaterials(float materialID, int amountToAdd) { if (amountToAdd <= 0) { Debug.LogError("Amount of materials to add cannot be 0 or less."); return(false); } else { if (MaterialIsAvailable(materialID)) { WoodshopMaterialCount w = AvailableMaterials.Find(x => x.MaterialID == materialID); int index = AvailableMaterials.IndexOf(w); w.Amount += amountToAdd; AvailableMaterials.Insert(index, w); } else { WoodshopMaterialCount newCount = new WoodshopMaterialCount { MaterialID = materialID, Amount = amountToAdd }; AvailableMaterials.Add(newCount); } return(true); } }
public bool RemoveMaterial(float materialID, int amountToRemove) { if (amountToRemove <= 0) { Debug.LogError("Amount of materials to remove cannot be 0 or less."); return(false); } else { if (MaterialIsAvailable(materialID)) { if (GetMaterialCount(materialID) - amountToRemove < 0) { throw new Exception("You don't have enough of this item (ID: " + materialID + ")"); } else { WoodshopMaterialCount w = AvailableMaterials.Find(x => x.MaterialID == materialID); w.Amount -= amountToRemove; if (w.Amount == 0) { AvailableMaterials.Remove(w); } return(true); } } else { throw new Exception("You don't have enough of this item (ID: " + materialID + ")"); } } }
public int GetMaterialCount(float materialID) { int count = 0; if (MaterialIsAvailable(materialID)) { WoodshopMaterialCount w = AvailableMaterials.Find(x => x.MaterialID == materialID); count = w.Amount; } return(count); }
public JsonResult RequestNewContent(int userId = 1) { var material = new AvailableMaterials(); var topicNames = material.GetTop3MaterialsForId(userId); const string msgFormat = "Your son needs a new topic select an option \n 1.{0} \n 2.{1} \n 3.{2}"; //TODO: Break down since for 130 chars if we are using the trial or 160 if not right now it only sends one message. var msg = String.Format(msgFormat, topicNames[0], topicNames[1], topicNames[2]); var response = SendSms(userId, msg); return(Json(response, JsonRequestBehavior.AllowGet)); }
public TwilioResponse ManageSms(SmsRequest request) { int controlNumber; string type; if (Int32.TryParse(request.Body, out controlNumber)) { switch (controlNumber) { case 1: case 2: case 3: var materials = new AvailableMaterials(); type = materials.GetTop3MaterialsForId(1)[controlNumber - 1]; break; default: throw new Exception("Response contained other characters that were not numbers"); break; } } else { //TODO:Handle This prettier throw new Exception("Response contained other characters that were not numbers"); } //TODO: Save The information of what type is and create and output for it. var blockBlob = CloudBlockBlob(); byte[] byteArray = Encoding.UTF8.GetBytes(type); using (var stream = new MemoryStream(byteArray)) { blockBlob.UploadFromStream(stream); } //System.IO.File.WriteAllText("holdData.txt", type); var re = new TwilioResponse(); re.Sms("Message Received"); return(re); }
public TwilioResponse ManageSms(SmsRequest request) { int controlNumber; string type; if (Int32.TryParse(request.Body, out controlNumber)) { switch (controlNumber) { case 1: case 2: case 3: var materials = new AvailableMaterials(); type = materials.GetTop3MaterialsForId(1)[controlNumber-1]; break; default: throw new Exception("Response contained other characters that were not numbers"); break; } } else { //TODO:Handle This prettier throw new Exception("Response contained other characters that were not numbers"); } //TODO: Save The information of what type is and create and output for it. var blockBlob = CloudBlockBlob(); byte[] byteArray = Encoding.UTF8.GetBytes(type); using (var stream = new MemoryStream(byteArray)) { blockBlob.UploadFromStream(stream); } //System.IO.File.WriteAllText("holdData.txt", type); var re = new TwilioResponse(); re.Sms("Message Received"); return re; }
public bool MaterialIsAvailable(float materialID) { WoodshopMaterialCount w = AvailableMaterials.Find(x => x.MaterialID == materialID); return(w != null); }
public JsonResult RequestNewContent(int userId=1) { var material = new AvailableMaterials(); var topicNames = material.GetTop3MaterialsForId(userId); const string msgFormat = "Your son needs a new topic select an option \n 1.{0} \n 2.{1} \n 3.{2}"; //TODO: Break down since for 130 chars if we are using the trial or 160 if not right now it only sends one message. var msg = String.Format(msgFormat, topicNames[0], topicNames[1], topicNames[2]); var response = SendSms(userId, msg); return Json(response, JsonRequestBehavior.AllowGet); }