public IEnumerable <Feedback> GetAll() { using (FeedbackDbContext _context = new FeedbackDbContext()) { return(FeedbackMapper.MapFeedbackPersistenceCollectionToFeedbackEntityCollection(_context.Feedbacks.ToList())); } }
public ActionResult Index(FeedbackViewModel submitModel) { using (var dbContext = FeedbackDbContext.Create()) { if (ModelState.IsValid) { var model = new Data.Feedback { Content = submitModel.Content, CreateTimestamp = DateTimeOffset.UtcNow, EmailAddress = submitModel.EmailAddress }; dbContext.Feedbacks.Add(model); dbContext.SaveChanges(); return(RedirectToAction(nameof(Index))); } var viewModel = new FeedbackListViewModel { Content = submitModel.Content, EmailAddress = submitModel.EmailAddress }; LoadFeedbackList(viewModel, dbContext); return(View(viewModel)); } }
private static async Task CalculateSentimentAsync(FeedbackDbContext dbContext) { // NOTE: Cognetive services accepts up to 1000 "documents" at a time. var feedbackBatch = dbContext.Feedbacks.Where(f => !f.SentimentScore.HasValue).Take(1000).ToList(); if (feedbackBatch.Any()) { Console.WriteLine("Found feedback to analyze..."); var documents = feedbackBatch.Select(f => new TextDocument(f.Id, f.Content)); var request = new TextAnalysisRequest(documents); var response = await TextAnalyzer.CalculateSentimentAsync(request); foreach (var sentiment in response.Documents) { var feedback = feedbackBatch.Single(f => f.Id == sentiment.Id); feedback.SentimentScore = sentiment.Score; } await dbContext.SaveChangesAsync(); await CalculateSentimentAsync(dbContext); // Recursively process until we are done. } else { Console.WriteLine("Did not find feedback to analyze."); } }
public static async Task TriggerCalculateSentimentAsync([TimerTrigger(Every1Minute, RunOnStartup = false)] TimerInfo info) { using (var dbContext = FeedbackDbContext.Create()) { await CalculateSentimentAsync(dbContext); } }
public void Create(Feedback entity) { using (FeedbackDbContext _context = new FeedbackDbContext()) { _context.Feedbacks.Add(FeedbackMapper.MapFeedbackEntityToFeedbackPersistence(entity)); _context.SaveChanges(); //ako ne sacuvamo nece se update-ovati baza } }
public IEnumerable <User> GetAll() { using (FeedbackDbContext _context = new FeedbackDbContext()) { //u _contextu se nalaze svi korisnici u bazi return(UserMapper.MapUserPersistenceCollectionToUserEntityCollection(_context.Users.ToList())); } }
public void Update(Feedback entity) { using (FeedbackDbContext _context = new FeedbackDbContext()) { //Entity Framework ce po id-ju naci feedback i azurirati ga _context.Update(FeedbackMapper.MapFeedbackEntityToFeedbackPersistence(entity)); _context.SaveChanges(); //moramo sacuvati promene } }
public Feedback GetById(Guid id) { using (FeedbackDbContext _context = new FeedbackDbContext()) { //pomocu lambda izraza se izvuce korisnik sa Id-jem koji je isti kao prosledjeni //isti rezultat ima i foreach gde se unutar nekog if-a porede id-jevi return(FeedbackMapper.MapFeedbackPersistenceToFeedbackEntity(_context.Feedbacks.SingleOrDefault(c => c.Id.Equals(id)))); } }
private static void LoadFeedbackList(FeedbackListViewModel viewModel, FeedbackDbContext dbContext) { viewModel.SubmittedFeedbacks = dbContext.Feedbacks.Select(f => new FeedbackViewModel { Content = f.Content, EmailAddress = f.EmailAddress, SentimentScore = f.SentimentScore }).ToList(); }
public List <Models.Feedback> GetListPaged <TKey>(int pageIndex, int pageSize, Expression <Func <Models.Feedback, bool> > expression, Expression <Func <Models.Feedback, TKey> > orderByExpression, bool isDesc, out int totalCount) { using (var dbContext = new FeedbackDbContext()) { var query = dbContext.Feedback.Where(expression); totalCount = query.Count(); query = isDesc ? query.OrderByDescending(orderByExpression) : query.OrderBy(orderByExpression); var list = query.Skip((pageIndex - 1) * pageSize).Take(pageSize).ToList(); return(list); } }
/// <summary> /// 根据来源id获取反馈列表 /// </summary> /// <param name="memberId"></param> /// <param name="souceId"></param> /// <param name="feedbackType"></param> /// <param name="sourceType"></param> /// <param name="pageIndex"></param> /// <param name="pageSize"></param> /// <param name="totalCount"></param> /// <returns></returns> public List <Models.Feedback> GetFeedbackListBySourceId(Guid memberId, Guid souceId, FeedbackType feedbackType, string sourceType, int pageIndex, int pageSize, out int totalCount) { using (var dbContext = new FeedbackDbContext()) { var query = dbContext.Feedback.Where(o => o.Status == FeedbackStatus.Normal && o.SourceId == souceId && o.FeedbackType == feedbackType && o.SourceType == sourceType && o.MemberId == memberId); totalCount = query.Count(); query = query.OrderByDescending(me => me.CreateTime); var list = query.Skip((pageIndex - 1) * pageSize).Take(pageSize).ToList(); return(list); } }
public bool Delete(Guid id) { using (FeedbackDbContext _context = new FeedbackDbContext()) { FeedbackPersistence feedback = _context.Feedbacks.Find(id); if (feedback == null) { return(false); //u principu vracamo true ili false, kao indikator uspesnosti operacije, ako ne pronadjemo id, operacija nije uspesna } _context.Feedbacks.Remove(feedback); _context.SaveChanges(); // cuvamo promene return(true); } }
public ActionResult Index() { var viewModel = new FeedbackListViewModel(); using (var dbContext = FeedbackDbContext.Create()) { try { dbContext.Database.Initialize(false); LoadFeedbackList(viewModel, dbContext); } catch (Exception e) { Debug.WriteLine($"Could not initialize database, probably because it doesn't exist yet. It'll get created by the VSTS Delivery Pipeline!\r\n{e}"); // NOTE: Obviously in real systems you wouldn't emit your connection string for the world to see! :) ViewData["Message"] = $"Attempted using connection string: {dbContext.Database.Connection.ConnectionString}\r\n{e.ToString()}"; } } return(View(viewModel)); }
public DataStore(FeedbackDbContext context) { _context = context; }
public FeedbackRepository(FeedbackDbContext context) : base(context) { }
public PostService(FeedbackDbContext db) { this.db = db; }
public IssuesQueries(FeedbackDbContext ctx, IRidesQueries ridesQueries) { _ctx = ctx; _ridesQueries = ridesQueries; }
public UserService(FeedbackDbContext context, IPasswordHasher <User> passwordHasher) { _context = context; _passwordHasher = passwordHasher; }
public SqlFeedbackData(FeedbackDbContext context) { _context = context; }
public UserService(FeedbackDbContext db) { this.db = db; }
public LookupService(FeedbackDbContext context) { _context = context; }
public ReviewService(FeedbackDbContext context) { _context = context; }
public UpdateIssueCommandHandler(FeedbackDbContext db, IRidesQueries ridesQueries) { _db = db; _ridesQueries = ridesQueries; }