public static model textToModel(Dictionary <string, List <string> > catExample, char split) { model textModel = new model(); for (int i = 0; i < catExample.Keys.Count; i++) { catagory cat = new catagory(); foreach (string example in catExample.Values.ElementAt(i)) { string[] parts = example.Split(split); for (int j = 0; j < parts.Length; j++) { if (!cat.frequency.ContainsKey(parts[j])) { cat.frequency.Add(parts[j], 0); } cat.frequency[parts[j]] += 1; } cat.total += parts.Length; } cat.id = catExample.Keys.ElementAt(i); textModel.catagories.Add(cat); } return(textModel); }
public async Task <ActionResult <catagory> > Postcatagory(catagory catagory) { _context.catagories.Add(catagory); await _context.SaveChangesAsync(); return(CreatedAtAction("Getcatagory", new { id = catagory.cat_Id }, catagory)); }
public async Task <IActionResult> Putcatagory(int id, catagory catagory) { if (id != catagory.cat_Id) { return(BadRequest()); } _context.Entry(catagory).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!catagoryExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public ActionResult DeleteConfirmed(int id) { catagory catagory = db.catagories.Find(id); db.catagories.Remove(catagory); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "cat_id,cat_name")] catagory catagory) { if (ModelState.IsValid) { db.Entry(catagory).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(catagory)); }
public ActionResult Create([Bind(Include = "cat_id,cat_name")] catagory catagory) { if (ModelState.IsValid) { db.catagories.Add(catagory); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(catagory)); }
// GET: catagory/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } catagory catagory = db.catagories.Find(id); if (catagory == null) { return(HttpNotFound()); } return(View(catagory)); }
public ActionResult getTopCategories() { List <TopCategory> topCategories = new List <TopCategory>(); var catlist = db.catagories.ToList(); foreach (var i in db.booking.GroupBy(e => e.CategoryId).Select(group => new { count = group.Count(), id = group.Key }).OrderByDescending(a => a.count)) { TopCategory tcat = new TopCategory { count = i.count, id = i.id }; catagory cat = catlist.FirstOrDefault(e => e.cat_Id == tcat.id); tcat.catname = cat.cat_Name; topCategories.Add(tcat); } return(Ok(topCategories)); }
public List <catagory> GetNoBudgetCateg(string id) { List <catagory> catList = new List <catagory>(); List <int> catListInt = new List <int>(); var list = _db.vendors.Where(a => a.vendor_id == id).ToList(); foreach (var n in list) { catListInt.Add(n.catt_id); } foreach (var ct in catListInt) { if (_db.venBudgets.FirstOrDefault(a => a.catt_id == ct) == null) { catagory categ = _db.catagories.FirstOrDefault(a => a.cat_Id == ct); catList.Add(categ); } } return(catList); }
public static model addTextToModel(string s, string classification, char split, model textModel) { int i = textModel.catagories.FindIndex((x) => x.id.Equals(classification)); string[] parts = s.Split(split); if (i == -1) { catagory cat = new catagory(); for (int j = 0; j < parts.Length; j++) { if (!cat.frequency.ContainsKey(parts[i])) { cat.frequency.Add(parts[i], 0); } cat.frequency[parts[i]] += 1; } cat.total = parts.Length; cat.id = classification; textModel.catagories.Add(cat); return(textModel); } else { catagory cat = textModel.catagories[i]; for (int j = 0; j < parts.Length; j++) { if (!cat.frequency.ContainsKey(parts[i])) { cat.frequency.Add(parts[i], 0); } cat.frequency[parts[i]] += 1; } cat.total += parts.Length; textModel.catagories[i] = cat; return(textModel); } }
public ActionResult <catagory> Postcat([FromBody] catagory c) { _context.catagories.Add(c); _context.SaveChanges(); return(Ok(c)); }
public bool catagoryHasFeature(catagory c, object feature) { return(c.frequency.ContainsKey(feature)); }