Exemplo n.º 1
0
 private FeedBack CreateMockFeedBack(int i)
 {
     var feedBack = new FeedBack()
     {
         FirstName = "FirstName-" + i,
         LastName = "LastName-" + i,
         FriendCircle = "College Friend",
         Handsome = 20,
         Helpful = 30,
         Intelligent = 40,
         Thoughtful = 50,
         Social = 60,
         Trustworthy = 70,
         GoodRemarks = new List<string>() { "Good at " + i},
         BadRemarks = new List<string>() { "Good at " + i },
     };
     if (i < 5)
     {
         feedBack.FromUserId = "User";
         feedBack.EmailId = "test" + i + "@gmail.com";
     }
     else
     {
         feedBack.FromUserId = "User-" + i;
         feedBack.EmailId = "[email protected]";
     }
     return feedBack;
 }
Exemplo n.º 2
0
 public bool SendFeedBack(string senderEmailId, FeedBack feedBack)
 {
     try
     {
         feedBack = _feedBackDataManager.SaveFeedBack(feedBack);
         try
         {
             var messageItem = new FeedBackMessageItem()
             {
                 SenderEmailId = senderEmailId,
                 FeedBack = feedBack,
                 RoutingKey = RoutingKeys.GAME_CREATED
             };
             _queue.Publish(messageItem);
         }
         catch (Exception ex)
         {
             ex.Data["FeedBackId"] = feedBack.Id;
             Logger.LogException(ex, _source, "SaveFeedBack", Severity.Normal);
         }
         return !string.IsNullOrEmpty(feedBack.Id);
     }
     catch (Exception ex)
     {
         Logger.LogException(ex, _source, "SaveFeedBack", Severity.Normal);
     }
     return false;
 }
Exemplo n.º 3
0
 public bool DeleteFeedBack(FeedBack feedBack)
 {
     var result = _client.Delete(feedBack);
     return IsServerError(result);
 }
Exemplo n.º 4
0
 public List<FeedBack> GetAllFeedBacksOfUser(string emailId)
 {
     var result = _client.Search<FeedBack>(d => d
         .Size(20000)
         .Query(q => q.Term(t => t.EmailId, emailId.ToLower()))
         .Fields(f => f.Helpful, f => f.Intelligent, f => f.Handsome, f => f.Social, f => f.Thoughtful, f => f.Trustworthy));
     IsServerError(result);
     List<FeedBack> feedBacks = new List<FeedBack>();
     foreach (var hit in result.Hits)
     {
         var f = new FeedBack()
         {
             Handsome = hit.Fields.FieldValues<FeedBack, decimal>(x => x.Handsome).SingleOrDefault(),
             Social = hit.Fields.FieldValues<FeedBack, decimal>(x => x.Social).SingleOrDefault(),
             Trustworthy = hit.Fields.FieldValues<FeedBack, decimal>(x => x.Trustworthy).SingleOrDefault(),
             Thoughtful = hit.Fields.FieldValues<FeedBack, decimal>(x => x.Thoughtful).SingleOrDefault(),
             Intelligent = hit.Fields.FieldValues<FeedBack, decimal>(x => x.Intelligent).SingleOrDefault(),
             Helpful = hit.Fields.FieldValues<FeedBack, decimal>(x => x.Helpful).SingleOrDefault(),
         };
         f.Id = hit.Id;
         feedBacks.Add(f);
     }
     return feedBacks;
 }
Exemplo n.º 5
0
        public FeedBack SaveFeedBack(FeedBack feedBack)
        {
            feedBack.EmailId = feedBack.EmailId.ToLower();
            var exFeedBack = GetFeedBack(feedBack.FromUserId, feedBack.EmailId);

            if (exFeedBack != null)
            {
                feedBack.Id = exFeedBack.Id;
                feedBack.AddedOn = exFeedBack.AddedOn;
                feedBack.UpdatedOn = DateTime.UtcNow;
                feedBack.FromUnknownUser = string.IsNullOrWhiteSpace(exFeedBack.FromUnknownUser)
                    ? feedBack.FromUnknownUser
                    : exFeedBack.FromUnknownUser;
                feedBack.Reply = null;
            }
            else
            {
                if (feedBack.AddedOn == DateTime.MinValue) feedBack.AddedOn = DateTime.UtcNow;
                if (feedBack.UpdatedOn == DateTime.MinValue) feedBack.UpdatedOn = DateTime.UtcNow;
            }
            var result = _client.Index(feedBack);
            IsServerError(result);
            feedBack.Id = result.Id;
            _client.Refresh();
            return feedBack;
        }