private string GetFormattedName(string songFileName) { var songFileLocation = GetSongFileLocation(songFileName); if (!string.IsNullOrWhiteSpace(songFileLocation)) { try { using (var file = TagLib.File.Create(songFileLocation)) { if (file.Tag.Performers.Length >= 1 && !string.IsNullOrWhiteSpace(file.Tag.Title)) { var performers = file.Tag.Performers.Where(x => !string.IsNullOrEmpty(x)).ToArray(); Array.Sort(performers); for (int i = 0; i < performers.Length; i++) { performers[i] = performers[i].Trim(); } return(Rater.FormatSongName(string.Join(", ", performers), file.Tag.Title)); } } } catch { //file type may not support tags, format normally } } return(Rater.FormatSongName(songFileName)); }
public ActionResult RateAccomodation(StuAccomRatings stuAccomRatings) { if (ModelState.IsValid) { Rater r = new Rater(); r.safety = stuAccomRatings.safety; r.service = stuAccomRatings.service; r.StudentAccomodationId = (int)TempData["RatingID"]; r.UsersId = 19; r.review = stuAccomRatings.review; try { SaveRating(r, stuAccomRatings); treedatStore.Rater.Add(r); treedatStore.SaveChanges(); } catch (Exception e) { e.ToString(); } } return(View()); }
public IHttpActionResult Delete(int id) { Rater rater = db.Raters.Find(id); db.Raters.Remove(rater); db.SaveChanges(); return(StatusCode(HttpStatusCode.NoContent)); }
private void UpdateRating(int pos, int rating) { var formattedName = GetFormattedName(CurrentSong); Rater.UpdateRating(formattedName, rating); Rater.SongsRatingsUpdated = true; UpdateColor(pos, rating); }
public IHttpActionResult Put(int id, Rater rater) { rater.Id = id; db.Entry(rater).State = EntityState.Modified; // Step 3 db.SaveChanges(); return(Ok()); }
public override int GetHashCode() { var hash = Rater.GetHashCode(); hash ^= RawRating.GetHashCode(); hash ^= PlayCount.GetHashCode(); hash ^= Dance?.Name.GetHashCode() ?? 0; return(hash); }
protected Rater[] Rate(string s) { Rater[] result = new Rater[allItems.Count]; for (int i = 0; i < result.Length; i++) { result[i] = RateItem(s, new Rater { Item = allItems[i] }); } return(result); }
public int SaveRating(Rater rateings, StuAccomRatings studentAccomodation) { SentimentAnalysis sentiment = new SentimentAnalysis(); if (ModelState.IsValid) { c2t = new ConvertToText(); treeNode = c2t.RetrieveTree(); foreach (ChildNode node in treeNode.ChildNodes) { if (node.data == studentAccomodation.IncomeGroup) { foreach (ChildNode area in node.Child) { if (area.data == studentAccomodation.location) { foreach (ChildNode acomodation in area.Child) { if (studentAccomodation.Name == acomodation.data) { int val = acomodation.Id; if (val > 0) { acomodation.Id = (val + (rateings.safety + rateings.service)) / 2; } else { acomodation.Id = rateings.safety + rateings.service; } acomodation.safety = rateings.safety; acomodation.sentiment += sentiment.DeterminePolarity(studentAccomodation.review); var t = treeNode; c2t.SaveTree(treeNode); break; } } } } } } return(1); } return(-1); }
public void Setup() { this.eval = new Evaluation { EvaluationID = 1 }; this.rater = new Rater { RaterID = 2, Name = "Michael Scarn", Role = "Spy", Email = "*****@*****.**", Answers = "5,1,5", EvaluationID = this.eval.EvaluationID, Evaluation = this.eval }; }
public bool CreateRater(RaterCreate model) { Rater rater = new Rater() { OwnerID = _userID, Branch = model.Branch, Job = model.Job, Rank = model.Rank, Age = model.Age, UserName = GetUserName() }; using (var ctx = new ApplicationDbContext()) { ctx.Raters.Add(rater); return(ctx.SaveChanges() == 1); } }
protected Rater RateItem(string search, Rater x) { var toSearch = search.ToLower(); var destination = keyAccessor(x.Item).ToLower(); bool firstMatch = true; for (var j = 0; j < toSearch.Length; j++) { if (destination == string.Empty) { return(x); } var currChar = toSearch[j]; var index = destination.IndexOf(currChar); if (index == -1) { continue; } x.FoundChars++; if (firstMatch) { x.Penalty += index; firstMatch = false; } else { x.Penalty += index * 1000; } if (index + 1 < destination.Length) { destination = destination.Substring(index + 1); } else { destination = string.Empty; } } return(x); }
private void MainForm_FormClosing(object sender, FormClosingEventArgs e) { try { if (Rater.SongsRatingsUpdated) { var dr = MessageBox.Show("Do you want to save your unsaved rating changes?", "Confirmation", MessageBoxButtons.YesNoCancel); if (dr == DialogResult.Yes) { Rater.SaveSongRatings(); } else if (dr == DialogResult.Cancel) { e.Cancel = true; } } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
// POST api/getups_packagerates //public void Post([FromBody]string value) //{ //} public string Post(FormDataCollection form) { try { ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; HelperFuncs.writeToSiteErrors("GetUPS_PackageRatesController", "GetUPS_PackageRatesController"); //HelperFuncs.writeToSiteErrors("GetUPS_PackageRatesController post string", form.ToString()); #region Get form data //HelperFuncs.writeToSiteErrors("data", form.Get("data")); //string username = form.Get("username"); //string password = form.Get("password"); //string originZip = form.Get("originZip"); //string destinationZip = form.Get("destinationZip"); //string[] additionalServices = new string[1]; //DateTime pickupDate; //if (!DateTime.TryParse(form.Get("pickupDate"), out pickupDate)) //{ // pickupDate = DateTime.Today.AddDays(1); //} #endregion //string doc = Rater.getPackageAPI_XML_Rate(ref form); return(Rater.getPackageAPI_XML_Rate(ref form)); } catch (Exception e) { HelperFuncs.writeToSiteErrors("GetUPS_PackageRatesController", e.ToString()); return("-1"); } }
public IHttpActionResult Post(Rater rater) { db.Raters.Add(rater); db.SaveChanges(); return(Created("Get", rater)); }
private void putRaterInGroup(List <Rater> supervisors, List <Rater> coworkers, List <Rater> supervisees, Rater rater) { switch (rater.Role) { case "Supervisor": supervisors.Add(rater); break; case "Coworker": coworkers.Add(rater); break; case "Supervisee": supervisees.Add(rater); break; } }
private void SaveRatings() { Rater.SaveSongRatings(); Rater.SongsRatingsUpdated = false; DisplayResponseMessage("Saved!"); }
public IHttpActionResult Get(int id) { Rater result = db.Raters.Find(id); return(Ok(result)); }