public IEnumerable<Opinion> FindOpinionsByExpert(string expert) { var connection = GetConnection(); connection.Open(); string sql = String.Format("select * from opinion where expert like '%{0}%' order by date desc", expert); SQLiteCommand command = new SQLiteCommand(sql, connection); SQLiteDataReader reader = command.ExecuteReader(); //date, signal, company, expert, opinion, price, symbol var opinions = new List<Opinion>(); while (reader.Read()) { var dateTime = new DateTime().AddTicks((long)reader["date"]); var o = new Opinion(dateTime, reader["signal"].ToString(), reader["company"].ToString(), reader["expert"].ToString(), reader["opinion"].ToString(), decimal.Parse(reader["price"].ToString()), reader["symbol"].ToString() ); opinions.Add(o); } connection.Close(); return NameHelpers.RemoveWeakNameMatches(opinions, expert); }
public object Put(Opinion opinion) { var session = this.GetSession(); if (session.UserName != opinion.user) { throw new HttpError(HttpStatusCode.MethodNotAllowed, "You can only edit your own opinions"); } Console.WriteLine("Put received opinion string = " + opinion.thingName); return Repository.Store(opinion); }
public async Task <IHttpActionResult> GetOpinion(int id) { Opinion opinion = await db.Opinion.FindAsync(id); if (opinion == null) { return(NotFound()); } return(Ok(opinion)); }
public ActionResult Edit([Bind(Include = "Id,CarId,Opinia,Ocena")] Opinion opinion) { if (ModelState.IsValid) { db.Entry(opinion).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.CarId = new SelectList(db.Cars, "CarId", "Model", opinion.CarId); return(View(opinion)); }
public OpinionViewModel ToOpinionViewModel(Opinion opinion) { return(new OpinionViewModel { Id = opinion.Id, Qualification = opinion.Qualification, Description = opinion.Description, Voy = opinion.Voy, Voy_id = opinion.Voy.Id }); }
public ActionResult <OpinionDto> Get(int id) { Opinion opinion = null; opinion = _TripAdvisorContext.Opinions.SingleOrDefault(opi => opi.id == id); if (opinion != null) { return(Ok(opinion.ToDto())); } return(NotFound()); }
public void UpdateText() { Text.text = 0.ToString(); ID1 = Character1.GetComponent <Dropdown>().value; ID2 = Character2.GetComponent <Dropdown>().value; //int intID1 = int.Parse (ID1); //int intID2 = int.Parse (ID2); Opinion Opinion = GameController.OpinionManager; Text.text = Opinion.OpinionList [ID1, ID2].ToString(); }
public ActionResult Customerservice2(int?id) { Opinion op = db.Opinions.Find(id); if (op == null) { return(RedirectToAction("Customerservice")); } return(View(op)); }
public bool PostUser([FromBody] Opinion opinion) { try { return(BL.OpinionLogic.AddOpinion(opinion)); } catch { return(false); } }
public ActionResult Edit([Bind(Include = "OpinionID,ReportID,UserCreatedID,DateCreated,Opinion1")] Opinion opinion) { if (ModelState.IsValid) { db.Entry(opinion).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.ReportID = new SelectList(db.Reports, "ReportID", "ReportName", opinion.ReportID); ViewBag.UserCreatedID = new SelectList(db.Users, "userID", "firstName", opinion.UserCreatedID); return(View(opinion)); }
public async Task <IActionResult> PostOpinion([FromBody] Opinion opinion) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _context.Opinions.Add(opinion); await _context.SaveChangesAsync(); return(CreatedAtAction("GetOpinion", new { id = opinion.ID }, opinion)); }
public ActionResult Edit([Bind(Include = "OpinionID,ReportID,MemberID,DateCreated,Opinion1,Status")] Opinion opinion) { if (ModelState.IsValid) { db.Entry(opinion).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index", "Project")); } //ViewBag.MemberID = new SelectList(db.Members, "MemberID", "MemberPosition", opinion.MemberID); //ViewBag.ReportID = new SelectList(db.Reports, "ReportID", "ReportName", opinion.ReportID); return(RedirectToAction("Index", "Project", new { id = opinion.Report.ProjectID, reportID = opinion.ReportID })); }
/// <summary> /// Metoda aktualizująca podany rekord w bazie danych /// </summary> /// <param name="opinion"></param> /// <returns></returns> public async Task <int> UpdateOpinionAsync(Opinion opinion) { if (opinion == null) { throw new Exception("Obiekt opinion nie może być pusty."); } _clinicRateDbContext.Opinions.Update(opinion); await _clinicRateDbContext.SaveChangesAsync(); return(opinion.OpinionId); }
public IActionResult Index(Opinion opinion) { if (ModelState.IsValid) { _opinionRepository.addOpinion(opinion); return(RedirectToAction("OpinionSend")); } else { return(View(opinion)); } }
private IEnumerable <Opinion> ParseOpinions(HtmlDocument doc) { var opinions = new List <Opinion>(); if (null == doc) { return(opinions); } var rows = doc.DocumentNode.SelectNodes("//div[@id='opinions']//tr"); // remove header rows.RemoveAt(0); foreach (var row in rows) { try { var date = row.SelectSingleNode(".//*[@class='date']").DecodedInnerText(); var signal = row.SelectSingleNode(".//*[contains(@class,'OpinionSignal')]").DecodedInnerText(); var company = row.SelectSingleNode(".//*[contains(@class,'company')]").DecodedInnerText(); var companyHtml = row.SelectSingleNode(".//*[contains(@class,'company')]").InnerHtml; var expert = row.SelectSingleNode(".//*[contains(@class,'expert')]").DecodedInnerText(); var opinionString = row.SelectSingleNode(".//*[contains(@class,'opinion')]").DecodedInnerText(); var price = row.SelectSingleNode(".//*[contains(@class,'price')]").DecodedInnerText(); var dateTime = DateTime.Parse(date); var priceValue = PriceToDecimal(price); string symbol = ""; try { symbol = Regex.Match(companyHtml, "<br>(?<sym>[^<]*)</a>").Groups["sym"].Value.Trim(); } catch {} var opinion = new Opinion { Date = dateTime, Signal = signal, Company = company, Expert = expert, OpinionString = opinionString, Price = priceValue, Symbol = symbol }; opinions.Add(opinion); } catch (Exception ex) { _failures++; } } return(opinions); }
public void AddOpinion(OpinionViewModel model) { var opinion = new Opinion { Date = model.PubDate, Content = model.Content, Author = model.Author }; _context.Opinions.Add(opinion); _context.SaveChanges(); }
public async Task <IHttpActionResult> PostOpinion(Opinion opinion) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.Opinion.Add(opinion); await db.SaveChangesAsync(); return(CreatedAtRoute("DefaultApi", new { id = opinion.OpinionId }, opinion)); }
public IHttpActionResult PostOpinion(Opinion opinion) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.Opinions.Add(opinion); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = opinion.OpinionId }, opinion)); }
public ActionResult Create([Bind(Include = "ID,Descripcion,ID_TrabajoRealizado")] Opinion opinion) { if (ModelState.IsValid) { db.Opinions.Add(opinion); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.ID_TrabajoRealizado = new SelectList(db.TrabajoRealizadoes, "ID", "ID", opinion.ID_TrabajoRealizado); return(View(opinion)); }
public ActionResult Edit([Bind(Include = "idOpinion,date,opinion1,points,Customer_idCustomer,Item_idItem")] Opinion opinion) { if (ModelState.IsValid) { db.Entry(opinion).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.Customer_idCustomer = new SelectList(db.Customers, "idCustomer", "name", opinion.Customer_idCustomer); ViewBag.Item_idItem = new SelectList(db.Items, "idItem", "name", opinion.Item_idItem); return(View(opinion)); }
public IActionResult Index(Opinion opinion) { if (ModelState.IsValid) { opinionRepository.AddOpinion(opinion); return(RedirectToAction("FeedbackSent")); } else { return(View(opinion)); } }
/// <summary> /// method to like or dislike post /// </summary> /// <param name="opinionType">like or dislike</param> /// <param name="postType">story or comment</param> /// <param name="userName">author of the story</param> /// <param name="title">title of the story</param> /// <param name="id">id if {postType} is comment</param> /// <param name="author">author of the opinion</param> /// <returns>if the opinion was added</returns> public async Task <bool> AddOpinionAsync(string opinionType, string postType, string userName, string title, int id, string author) { try { Opinion opinion = new Opinion(author); opinion.Date = DateTime.Now; // first we need to delete user's like/dislike if he did it before await DeleteOpinionAsync(opinionType == LIKE?DISLIKE : LIKE, postType, userName, title, id, opinion.Author); IPostable post = await GetPostWithGivenType(postType, userName, title, id); if (post == null) { return(false); } switch (opinionType) { case LIKE: if (post.Likes.FindIndex(op => op.Author == opinion.Author) == -1) { post.Likes.Add(opinion); } break; case DISLIKE: if (post.Dislikes.FindIndex(op => op.Author == opinion.Author) == -1) { post.Dislikes.Add(opinion); } break; default: _logger.LogDebug($"invalid type of the opinion"); break; } return(await UpdatePostWithGivenType(postType, userName, title, post)); } catch (Exception e) { _logger.LogError($"Error while adding opinion\n {e.Message}"); } return(false); }
public bool AddOpinion(Opinion opinion) { foreach (var driver in list) { if (opinion.Driver.Drv_Identity == driver.Drv_Identity) { driver.OpinionList.Add(opinion); return(true); } } return(false); }
public async Task <bool> UpdateOpinion(School school, Opinion opinion) { if (school == null) { throw new EntityNotFoundException("Szkółka"); } opinion.UpdateDate(); UpdateSchoolRating(school); return(await database.Complete()); }
public void BadMarksOpinion(int mark) { Doctor d = new Doctor("Testowy", "Doktor", "*****@*****.**", "123456", "Zarzadzania"); Student s = new Student("Imie", "Nazwisko", "*****@*****.**", "123456", "Zarzadzania"); Thesis t = new Thesis("Przykladowy temat", s); Opinion o = new Opinion(d, t, mark, "opinia"); var actual = o.Mark; var expected = mark; Assert.AreEqual(expected, actual); }
public void SetVisibleEdit() { textBox1.ReadOnly = false; textBox2.ReadOnly = false; textBox3.ReadOnly = false; groupBox1.Enabled = true; pictureBox1.Visible = true; pictureBox2.Visible = true; label7.Visible = true; groupBox2.Visible = true; Description.SetVisibleEdit(); Opinion.SetVisibleEdit(); }
public ActionResult Create([Bind(Include = "Id,CarId,UserId,Opinia,Ocena")] Opinion opinion) { if (ModelState.IsValid) { db.Opinions.Add(opinion); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.CarId = new SelectList(db.Cars, "CarId", "Model", opinion.CarId); // ViewBag.UserId = new SelectList(db.ApplicationUsers, "Id", "Imie", opinion.UserId); return(View(opinion)); }
public async Task <IActionResult> Upsert(Opinion opinionObj) { if (ModelState.IsValid) { if (opinionObj == null) { return(NotFound()); } var returnedTuple = await _accountRepo.GetUserId(SD.AccountApi, User.Identity.Name, HttpContext.Session.GetString("JWToken")); if (returnedTuple.Item1 != "") { TempData["error"] = returnedTuple.Item1; //return View(opinionObj); return(RedirectToAction("ReadForumPost", "ForumPost", new { id = opinionObj.ForumPostId })); } opinionObj.UserId = returnedTuple.Item2; if (opinionObj.Id == 0) { var result = await _opinionRepo.CreateAsync(SD.Opinions, opinionObj, HttpContext.Session.GetString("JWToken")); if (result.Item1 != "") { TempData["error"] = result.Item1; //return View(opinionObj); return(RedirectToAction("ReadForumPost", "ForumPost", new { id = opinionObj.ForumPostId })); } } else { var result = await _opinionRepo.UpdateAsync(SD.Opinions, opinionObj.Id, opinionObj, HttpContext.Session.GetString("JWToken")); if (result.Item1 != "") { TempData["error"] = result.Item1; //return View(opinionObj); return(RedirectToAction("ReadForumPost", "ForumPost", new { id = opinionObj.ForumPostId })); } } return(RedirectToAction("ReadForumPost", "ForumPost", new { id = opinionObj.ForumPostId })); } else { //return View(opinionObj); return(RedirectToAction("ReadForumPost", "ForumPost", new { id = opinionObj.ForumPostId })); } }
public void Should_get_stats_whe_using_lazy() { using (var store = GetDocumentStore()) { new TheIndex().Execute(store); using (var session = store.OpenSession()) { for (var i = 0; i < 15; i++) { var entity = new Entity { DisplayName = "Entity " + i, UpdatedAt = DateTimeOffset.Now, Visibility = "Visible" }; session.Store(entity); var opinion = new Opinion { EntityId = entity.Id, IsFavorite = i % 2 == 0 }; session.Store(opinion); } session.SaveChanges(); } using (var session = store.OpenSession()) { QueryStatistics stats; var query = session.Query <Summary, TheIndex>() .Customize(x => x.WaitForNonStaleResults()) .Statistics(out stats) .Where(x => x.Visibility == "Visible") .OrderByDescending(x => x.UpdatedAt); var pagedQuery = query .Skip(0) .Take(10) .Lazily(); var items = pagedQuery.Value.ToArray(); Assert.Equal(15, stats.TotalResults); Assert.Equal(10, items.Length); } } }
public IHttpActionResult DeleteOpinion(int?id) { Opinion opinion = db.Opinions.Find(id); if (opinion == null) { return(NotFound()); } db.Opinions.Remove(opinion); db.SaveChanges(); return(Ok(opinion)); }
public async Task <IHttpActionResult> DeleteOpinion(int id) { Opinion opinion = await db.Opinion.FindAsync(id); if (opinion == null) { return(NotFound()); } db.Opinion.Remove(opinion); await db.SaveChangesAsync(); return(Ok(opinion)); }
public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Opinion opinion = db.Opinions.Find(id); if (opinion == null) { return(HttpNotFound()); } return(View(opinion)); }
public static List<Opinion> GetOpinions(string keywords) { List<Opinion> opinions = new List<Opinion>(); try { WebClient webClient = new WebClient(); webClient.Encoding = Encoding.UTF8; string requestUrl = string.Format( "http://api.appinions.com/search/v2/opinions?appkey={0}&doc_text={1}&start=0&rows={2}&format=xml&dedup=true", APP_KEY, keywords, MAX_RETURN); string xml = webClient.DownloadString(requestUrl); XmlDocument doc = new XmlDocument(); doc.LoadXml(xml); XmlNodeList list = doc.SelectNodes("//opinion"); foreach (XmlNode node in list) { Opinion o = new Opinion() { pre_sent = node.SelectSingleNode("pre_sent").InnerText, sent = node.SelectSingleNode("sent").InnerText, post_sent = node.SelectSingleNode("post_sent").InnerText, doc_title = node.SelectSingleNode("doc_title").InnerText, doc_link = node.SelectSingleNode("doc_link").InnerText }; DateTime.TryParse(node.SelectSingleNode("publish_date").InnerText, out o.publish_date); if (!opinions.Contains(o)) opinions.Add(o); } } catch (Exception e) { Logger.Error("Remix Error", e); } return opinions; }
public ActionResult SendOpinion(string placeId, string opinion) { int cuurentPlaceId = int.Parse(placeId); if (opinion.Length > ModelConstants.MinOpinionLenght || opinion.Length < ModelConstants.MessageMaxLenght) { var newOpinion = new Opinion { Content = opinion, PlaceId = cuurentPlaceId }; this.placeService.AddNewOpinion(newOpinion); List<string> tags = ExtractTagsFromOpinion(opinion); this.placeService.AddTags(cuurentPlaceId, tags); } return this.RedirectToAction("Index"); }
public object Store(Opinion opinion) { try { var matchingOpinions = GetByName(opinion.thingName, opinion.user); // did the opinion already exist? if so, update, else insert. if (matchingOpinions.Any()) { var matchingOpinion = matchingOpinions.First(); opinion.id = matchingOpinion.id; if (String.IsNullOrEmpty(opinion.rant)) { opinion.rant = matchingOpinion.rant; } using (var connection = connectionFactory.Connect()) { connection.Update(opinion); } } else { using (var connection = connectionFactory.Connect()) { connection.Insert(opinion); } } return opinion; } catch (Exception e) { logger.ErrorException("attempted to update/inset a opinion", e); throw new HttpError(HttpStatusCode.InternalServerError, "exception while trying to update/insert opinion"); } }
private IEnumerable<Opinion> ParseOpinions(HtmlDocument doc) { var opinions = new List<Opinion>(); if (null == doc) return opinions; var rows = doc.DocumentNode.SelectNodes("//div[@id='opinions']//tr"); // remove header rows.RemoveAt(0); foreach (var row in rows) { try { var date = row.SelectSingleNode(".//*[@class='date']").DecodedInnerText(); var signal = row.SelectSingleNode(".//*[contains(@class,'OpinionSignal')]").DecodedInnerText(); var company = row.SelectSingleNode(".//*[contains(@class,'company')]").DecodedInnerText(); var companyHtml = row.SelectSingleNode(".//*[contains(@class,'company')]").InnerHtml; var expert = row.SelectSingleNode(".//*[contains(@class,'expert')]").DecodedInnerText(); var opinionString = row.SelectSingleNode(".//*[contains(@class,'opinion')]").DecodedInnerText(); var price = row.SelectSingleNode(".//*[contains(@class,'price')]").DecodedInnerText(); var dateTime = DateTime.Parse(date); var priceValue = PriceToDecimal(price); string symbol = ""; try { symbol = Regex.Match(companyHtml, "<br>(?<sym>[^<]*)</a>").Groups["sym"].Value.Trim(); } catch {} var opinion = new Opinion ( dateTime, signal, company, expert, opinionString, priceValue, symbol ); opinions.Add(opinion); } catch(Exception ex) { _failures++; } } return opinions; }