void CheckForEmailAddress()
		{
			Trace.Write("CheckingForEmailAddress");
			RegularExpression regex = new RegularExpression(EmailRegex);
			string email = selector.Text.Trim();
			if (regex.Test(email))
			{
				Suggestion suggestion = new Suggestion();
				suggestion.html = GetPicTitleDetailTemplateHtml(@"/gfx/icon40-inbox.png", "Add " + selector.Text.Trim() + " as a buddy", "When they join DontStayIn they will be added as one of your buddies.  If you type a name after the email address you can use that in future to find this person.");
				suggestion.text = selector.Text;
				suggestion.value = "{'email': '" + selector.Text.Escape() + "'}";
				suggestion.priority = selector.Text.Length * 100;
				for (int i = 0; i < selector.Suggestions.Count; i++)
				{
					if (selector.Suggestions[i].value.StartsWith("{'email': "))
					{
						selector.Suggestions.RemoveAt(i);
						break;
					}
				}
				selector.AddSuggestion(suggestion);
				selector.DisplaySuggestionsInPopupMenu();
			}
			if (oldOnSuggestionsRequested != null) oldOnSuggestionsRequested();
		}
        public string Autosuggest(string autocomplete)
        {
            const string autocompletionName = "destination-suggest";
            var response =
                _elasticClient.Suggest<string>(suggest => suggest.Completion(autocompletionName, c => c.Size(100).OnField("suggest").Text(autocomplete).Fuzzy(fuzzy=> fuzzy.Fuzziness(1).Transpositions(false))));

            var options = response.Suggestions[autocompletionName][0].Options;

            var fuzzySuggestions = new List<Suggestion>();

            var exactMatchSuggestions = new List<Suggestion>();

            foreach (var option in options)
            {
                var suggestion = new Suggestion
                {
                    Text = option.Text,
                    Payload = option.Payload,
                    Score = option.Score
                };

                if (option.Text.ToUpperInvariant().StartsWith(autocomplete.ToUpperInvariant()))
                    exactMatchSuggestions.Add(suggestion);
                else fuzzySuggestions.Add(suggestion);
            }

            var suggestions = exactMatchSuggestions.Concat(fuzzySuggestions);

            return JsonConvert.SerializeObject(suggestions.Select(y => y.Text).ToList());
        }
Example #3
0
		/// <summary>
		/// 
		/// </summary>
		/// <param name="input"></param>
		/// <param name="candidates"></param>
		/// <param name="suggestions">Null if no suggestions</param>
		/// <returns></returns>
		public Suggestion AutoComplete ( string input )
		{
			if (string.IsNullOrWhiteSpace(input)) {
				return new Suggestion("");
			}

			var suggestion = new Suggestion(input);

			var args = CommandLineParser.SplitCommandLine( input ).ToArray();

			var cmd  =	args[0];

			var cmdList =	CommandList
							.ToList();

			var varList	=	variables.Select( a => a.Value )
							.OrderBy( b => b.FullName )
							.ToList();


			string longestCommon = null;
			int count = 0;

			//
			//	search commands :
			//	
			foreach ( var name in cmdList ) {
				if (cmd.ToLower()==name.ToLower()) {
					return AutoCompleteCommand(input, args, name);
				}
				if (name.StartsWith(cmd, StringComparison.OrdinalIgnoreCase)) {
					longestCommon = LongestCommon( longestCommon, name );
					suggestion.Set( longestCommon );
					suggestion.Add( name );
					count++;
				}
			}

			//
			//	search variables :
			//	
			foreach ( var variable in varList ) {
				if (cmd.ToLower()==variable.FullName.ToLower()) {
					return AutoCompleteVariable( input, args, variable );
				}		   
				if (variable.FullName.StartsWith(cmd, StringComparison.OrdinalIgnoreCase)) {
					longestCommon = LongestCommon( longestCommon, variable.FullName );
					suggestion.Set( longestCommon );
					suggestion.Add( string.Format("{0,-30} = {1}", variable.FullName, variable.Get() ) );
					count++;
				}
			}

			if (count==1) {
				suggestion.Set( suggestion.CommandLine + " ");
			}

			return suggestion;
		}
Example #4
0
        /// <summary>
        /// Displays all links for the given suggestion.
        /// </summary>
        /// <param name="suggestion">Suggestion to display links for.</param>
        internal static void Display(Suggestion suggestion)
        {
            var menuItems = suggestion.Links.ConvertAll(i => CreateMenuItem("\"" + i.Key + "\"", i.Value, null));
            menuItems.Add(SimpleMenuItem.CreateSeparator());
            menuItems.Add(CreateExplanationMenuItem(suggestion.ResharperName));

            Display("How about this", menuItems);
        }
        public void SingleValidSuggestion_SuggestionAddedToNewScopeOnLeft_usesMatchIndex()
        {
            Scope root = new Scope("abc");
            Suggestion Asuggestion = new Suggestion("a", "the letter a");
            auto.LearnAutomaticRules(Asuggestion);
            auto.AutoScope(root);

            Assert.AreEqual(Asuggestion,root.InnerLeftScope.Suggestions[0]);
        }
	public void ShowSuggestion(Suggestion suggestion){
        //TODO: Insert a canvas and show the suggestion on the baloon
		HideSuggestion();
		currentSuggestion = suggestion;
        oldPosition = suggestion.transform;
		suggestion.transform.position = GameManager.instance.suggestionButton.position;
       // Debug.Log("Suggestion invoked in " + suggestion.transform.position.x);
		Invoke("HideSuggestion", suggestionTime);
	}
        public void SingleValidSuggestion_SuggestionAddedToNewScope()
        {
            Scope root = new Scope("abc");
            Suggestion Bsuggestion = new Suggestion("b", "the letter b");
            auto.LearnAutomaticRules(Bsuggestion);
            auto.AutoScope(root);

            Assert.AreEqual(Bsuggestion,root.InnerMiddleScope.Suggestions[0]);
        }
        public void SingleValidSuggestion_SuggestionAddedToNewScopeImplicitly()
        {
            Scope root = new Scope("abc");
            Suggestion Bsuggestion = new Suggestion("b", "the letter b");
            auto.LearnAutomaticRules(Bsuggestion);
            auto.AutoScope(root);

            Assert.IsTrue(root.InnerMiddleScope.IsExplicit);
        }
Example #9
0
        public CodeCompletionData(Context context, Suggestion suggestion)
        {
            Ensure.ArgumentNotNull(suggestion,"suggestion");

            Suggestion = suggestion;
            Context = context;
            Text = suggestion.Text;
            Content = suggestion.Text;
        }
		public void AddRange(Suggestion[] newSuggestions)
		{
			for (int i = 0; i < newSuggestions.Length; i++)
			{
				AddWithoutSortOrNotify(newSuggestions[i]);
			}
			Sort();
			if (OnSuggestionsChanged != null) OnSuggestionsChanged();
		}
        public void SimpleScopeWith1SuggestionInInner()
        {
            string filename = TEST_FILE_NAME;
            Scope s = new Scope("abc");
            Suggestion sug = new Suggestion("a","b");
            s.DefineInnerScope(1,1).Suggestions.Add(sug);
            s.Save<Scope>(filename);

            Scope loaded = Scope.Load<Scope>(filename);
            Assert.AreEqual(sug, loaded.InnerMiddleScope.Suggestions[0]);
        }
        // POST: api/SuggestionAPI
        public void Post([FromBody]string value)
        {
            using (var obj = new SnaFoo.natEntities())
            {
                var suggestion = new Suggestion();
                suggestion.SnackId = Int32.Parse(value);
                suggestion.SuggestedOn = DateTime.Now;

                obj.Suggestions.Add(suggestion);
                obj.SaveChanges();
            }
        }
		private void AddWithoutSortOrNotify(Suggestion newSuggestion)
		{
			int i = 0;
			for (i = 0; i < suggestions.Length; i++)
			{
				Suggestion current = (Suggestion)suggestions[i];
				if (current.value == newSuggestion.value)
				{
					if (newSuggestion.priority < current.priority) { newSuggestion.priority = current.priority; }
					break;
				}
			}
			suggestions[i] = newSuggestion;
		}
 public WeatherSuggestion(JsonContract.WeatherSuggestionContract suggestion)
 {
     if (suggestion == null)
     {
         return;
     }
     Comfortable = new Suggestion(suggestion.comf);
     CarWashing = new Suggestion(suggestion.cw);
     Dressing = new Suggestion(suggestion.drsg);
     Flu = new Suggestion(suggestion.flu);
     Sport = new Suggestion(suggestion.sport);
     UV = new Suggestion(suggestion.uv);
     Trav = new Suggestion(suggestion.trav);
 }
		void CheckForEmailAddresses()
		{
			Trace.Write("CheckingForEmailAddresses");
			RegularExpression regExp = new RegularExpression(@"\s|,|;| +", "g");
			string text = selector.Text.ReplaceRegex(regExp, " ");
			while (text.IndexOf("  ") > -1)
			{
				text = text.Replace("  ", " ");
			}
			text = text.Trim();
			for (int i = selector.Suggestions.Count - 1; i > -1; i--)
			{
				Trace.Write(selector.Suggestions[i].value);
				if (selector.Suggestions[i].value.StartsWith("{'emails': "))
				{
					selector.Suggestions.RemoveAt(i);
					break;
				}
			}
			RegularExpression regex = new RegularExpression(EmailsRegex);
			if (regex.Test(text))
			{
				selector.Text = text;
				selector.Suggestions.Clear();
				string[] emails = text.Split(" ");
				Suggestion suggestion = new Suggestion();
				suggestion.html = GetPicTitleDetailTemplateHtml(@"/gfx/icon40-inbox.png", "Add " + emails.Length + " email addresses as buddies", "Next time you want to include these email addresses, just add all your buddies and they will be included.");
				suggestion.text = emails.Length + " email addresses as buddies";
				suggestion.value = "{'emails': '" + text.Escape() + "', 'buddies':'true'}";
				suggestion.priority = selector.Text.Length * 100;
				selector.AddSuggestion(suggestion);

				Suggestion suggestion2 = new Suggestion();
				suggestion2.html = GetPicTitleDetailTemplateHtml(@"/gfx/icon40-inbox.png", "Add " + emails.Length + " email addresses, but NOT as buddies", "Next time you want to include these email addresses you'll have to copy them in again");
				suggestion2.text = emails.Length + " email addresses";
				suggestion2.value = "{'emails': '" + text.Escape() + "', 'buddies':'false'}";
				suggestion2.priority = selector.Text.Length * 100;
				selector.AddSuggestion(suggestion2);
				
				
				selector.DisplaySuggestionsInPopupMenu();
				
			}
			if (oldOnSuggestionsRequested != null) oldOnSuggestionsRequested();
		}
 public static SuggestionAddedNotification Deserialize(Stream stream, SuggestionAddedNotification instance, long limit)
 {
     while (limit < 0L || stream.Position < limit)
     {
         int num = stream.ReadByte();
         if (num == -1)
         {
             if (limit >= 0L)
             {
                 throw new EndOfStreamException();
             }
             return(instance);
         }
         else if (num != 10)
         {
             Key  key   = ProtocolParser.ReadKey((byte)num, stream);
             uint field = key.Field;
             if (field == 0u)
             {
                 throw new ProtocolBufferException("Invalid field id: 0, something went wrong in the stream");
             }
             ProtocolParser.SkipKey(stream, key);
         }
         else if (instance.Suggestion == null)
         {
             instance.Suggestion = Suggestion.DeserializeLengthDelimited(stream);
         }
         else
         {
             Suggestion.DeserializeLengthDelimited(stream, instance.Suggestion);
         }
     }
     if (stream.Position == limit)
     {
         return(instance);
     }
     throw new ProtocolBufferException("Read past max limit");
 }
Example #17
0
        private async Task MessageCreated(MessageCreateEventArgs e)
        {
            if (Program.pairs.Count != 0 && Program.pairs.Any(x => x.InputPair == e.Channel.Id))
            {
                Suggestion sg = new Suggestion(e.Message);
                if (sg.Image.HasValue || sg.Links.Count != 0)
                {
                    try
                    {
                        await e.Message.CreateReactionAsync(DiscordEmoji.FromName(e.Client, ":+1:"));

                        await e.Message.CreateReactionAsync(DiscordEmoji.FromName(e.Client, ":-1:"));

                        await e.Message.CreateReactionAsync(DiscordEmoji.FromName(e.Client, ":white_check_mark:"));
                    }
                    catch (Exception ex)
                    {
                        StringBuilder data = new StringBuilder();
                        Console.WriteLine($"[EX <{ex.Message}> @ Sug.cs : MessageCreatedEvent] \n\t{ex}");
                    }
                }
            }
        }
Example #18
0
        public void AddFromSuggestion(Booking time)
        {
            Logger.Info(this, "Adding to repository"); // TODO
            int        id_to_add        = time.Id;
            Suggestion check_suggestion = _context.Suggestions.Where(s => s.Id == id_to_add).FirstOrDefault();
            Booking    check_booking    = _context.Bookings.Where(b => b.Id == id_to_add).FirstOrDefault();

            Logger.Info(this, "Got check_booking"); // TODO
            if ((check_booking == null) && (check_suggestion == null))
            {
                Logger.Info(this, "check_booking was null");       // TODO
                _context.Bookings.Add(time);
                Logger.Info(this, "Booking was added to context"); // TODO
                _context.SaveChanges();                            // 500 internal server error
                Logger.Info(this, "Context was saved");            // TODO
            }
            else
            {
                Logger.Info(this, "check_booking was not null"); // TODO
                throw new System.InvalidOperationException("Id of booking is already in use");
            }
            Logger.Info(this, "Exiting repository"); // TODO
        }
Example #19
0
 public ActionResult Delete(Suggestion obj)
 {
     if (User.Identity.Name.Split('|')[2].Equals("2"))
     {
         DBDal dal = new DBDal();
         if (obj != null)
         {
             List <Suggestion> suggest = (from u in dal.Suggestions
                                          where (u.ID == obj.ID)
                                          select u).ToList();
             dal.Suggestions.Remove(suggest.First());
             dal.SaveChanges();
         }
         List <Suggestion>   objSuggests  = dal.Suggestions.ToList <Suggestion>();
         SuggestionViewModel suggestionvm = new SuggestionViewModel();
         suggestionvm.suggestions = objSuggests;
         return(View("PrintSuggests", suggestionvm));
     }
     else
     {
         return(RedirectToRoute("DefaultPage"));
     }
 }
        public async Task DeleteAsyncTestHappy()
        {
            // Arrange
            var        mockSuggestionRepository = GetDefaultISuggestionRepositoryInstance();
            var        mockUserRepository       = GetDefaultIUserRepositoryInstance();
            var        mockUnitOfWork           = GetDefaultIUnitOfWorkInstance();
            Suggestion suggestion   = new Suggestion();
            int        suggestionId = 1;

            suggestion.Id = suggestionId;

            mockSuggestionRepository.Setup(r => r.FindById(suggestionId))
            .Returns(Task.FromResult <Suggestion>(suggestion));

            var service = new SuggestionService(mockSuggestionRepository.Object,
                                                mockUnitOfWork.Object, mockUserRepository.Object);

            // Act
            SuggestionResponse result = await service.DeleteAsync(suggestionId);

            // Assert
            Assert.AreEqual(suggestion, result.Resource);
        }
        public void Db_UpdatesChanges_Test()
        {
            //Arrange
            Suggestion newSuggestion = new Suggestion()
            {
                City        = "Portland",
                Country     = "USA",
                Description = "Rainy"
            };

            repo.Add(newSuggestion);
            var suggestionId    = newSuggestion.Id;
            var foundSuggestion = repo.Find(suggestionId);
            //Act
            var newName = "Houston";

            foundSuggestion.City = newName;
            repo.Edit(foundSuggestion);
            var changedSuggestion = repo.Find(suggestionId);

            //Assert
            Assert.Equal(newName, changedSuggestion.City);
        }
Example #22
0
    private static void WriteInfo(Suggestion _suggestion)
    {
        int cursorPosTop  = Console.CursorTop;
        int cursorPosLeft = Console.CursorLeft;
        int offset        = Program.profileName.Length + 2;

        if (_suggestion.info == null ||
            Console.WindowWidth <= offset + _suggestion.info.Length)
        {
            return;
        }

        Console.SetCursorPosition(offset, cursorPosTop + 1);
        Console.BackgroundColor = ConsoleColor.DarkRed;
        Console.ForegroundColor = ConsoleColor.White;
        Console.Write(_suggestion.info);
        Console.ResetColor();

        Console.SetCursorPosition(cursorPosLeft, cursorPosTop);

        currentInfo    = _suggestion.info;
        currentInfoRow = cursorPosTop + 1;
    }
Example #23
0
        public override IEnumerable <VMStatus> SelectStatusforEdit(int IdSuggestion)
        {
            Suggestion             sug      = _dataContext.Suggestion.Include(r => r.Status).SingleOrDefault(x => x.Id == IdSuggestion);
            IEnumerable <VMStatus> statuses = null;

            if (sug.Status.Id == 1)
            {
                statuses = _models.Where(p => p.Id == 2 || p.Id == 3).Select(row => new VMStatus()
                {
                    Id          = row.Id,
                    Description = row.Description,
                }).ToList();;
            }
            if (sug.Status.Id == 2)
            {
                statuses = _models.Where(p => p.Id == 4).Select(row => new VMStatus()
                {
                    Id          = row.Id,
                    Description = row.Description,
                }).ToList();;
            }
            return(statuses);
        }
 private void MakeSuggestions()
 {
     BuyingSuggestion = new Suggestion
     {
         HighLimit = FiveBasicNumber.SixtyEightHigh,
         LowLimit  = FiveBasicNumber.SixtyEightLow
     };
     SellingSuggestion = new Suggestion
     {
         HighLimit = FiveBasicNumber.NinetyNineHigh,
         LowLimit  = FiveBasicNumber.NinetyLow
     };
     HoldOrBuySuggestion = new Suggestion
     {
         HighLimit = FiveBasicNumber.SixtyEightLow,
         LowLimit  = FiveBasicNumber.NinetyLow
     };
     HoldOrSellSuggestion = new Suggestion
     {
         HighLimit = FiveBasicNumber.NinetyNineHigh,
         LowLimit  = FiveBasicNumber.SixtyEightHigh
     };
 }
Example #25
0
        public override string TInsert(VMSuggestion viewModel)
        {
            Suggestion model = new Suggestion()
            {
                Title        = viewModel.Title,
                Description  = viewModel.Description,
                QuantityVote = viewModel.QuantityVote,
                CreatedDate  = viewModel.CreatedDate,
                UpdatedDate  = viewModel.UpdatedDate,
                Author       = _dataContext.User.Find(viewModel.IdAuthor),
                Status       = _dataContext.Status.Find(viewModel.StatusId)
            };

            _models.Add(model);
            _dataContext.SaveChanges();
            viewModel.Id = model.Id;
            //send email to the moderator of the suggestion created for user

            _dataContext.Database.ExecuteSqlCommand("exec EmailModeratorSuggestion @SuggestioId, @statusId",
                                                    new SqlParameter("@SuggestioId", viewModel.Id),
                                                    new SqlParameter("@statusId", model.Status.Id));
            return(model.Id.ToString());
        }
Example #26
0
        public IActionResult GetSuggestions(Filter queryObj)
        {
            if (string.IsNullOrEmpty(queryObj.q))
            {
                return(BadRequest());
            }

            string path       = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot", "DataSource", "GeoName.json");
            string jsonString = System.IO.File.ReadAllText(path);

            var SuggestionList = JsonConvert.DeserializeObject <List <Suggestion> >(jsonString);

            var SuggestList = QuerySuggestionListByFilter(SuggestionList, queryObj);

            var outSuggestionList = new List <Suggestion>();

            foreach (var suggestion in SuggestList)
            {
                var suggestToSearch = new Suggestion()
                {
                    GeoName = suggestion.GeoName, Latitude = suggestion.Latitude, Longitude = suggestion.Longitude
                };
                float score = GetCountOfMatchQueryHasInObject(suggestToSearch, queryObj);
                if (score > 0)
                {
                    suggestion.Score = Math.Round((score / SuggestList.Count), 2);
                    outSuggestionList.Add(suggestion);
                }
            }

            string json = JsonConvert.SerializeObject(new
            {
                Suggestions = outSuggestionList.OrderByDescending(s => s.Score)
            }, Formatting.Indented);

            return(Ok(JObject.Parse(json)));
        }
Example #27
0
        [Route("update-suggestion")] //??
        public async Task <ActionResult> Update([FromBody] Suggestion suggestion)
        {
            if (suggestion == null)
            {
                return(NotFound("Bos"));
            }
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            Suggestion existinSuggestion = _kaizenContext.Suggestions.FirstOrDefault(s => s.Id == suggestion.Id);

            if (existinSuggestion == null)
            {
                return(NotFound("Böyle bir öneri bulunmamaktadır."));
            }
            existinSuggestion.Name           = suggestion.Name;
            existinSuggestion.SuggestionText = suggestion.SuggestionText;
            _kaizenContext.Attach(existinSuggestion).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
            await _kaizenContext.SaveChangesAsync();

            return(Ok(existinSuggestion));
        }
Example #28
0
        public override Suggestion Create(Suggestion dataObject)
        {
            using (IDAL dal = this.DAL)
            {
                dal.BeginTransaction();
                try
                {
                    dataObject.Organization = OTApplication.Context.Organization.Id;
                    // dataObject.Event = _parameterReader.ReadEventId("Make Suggestion");
                    dataObject.SuggestionId = dal.Create(dataObject);

                    startSuggestionProcess(dataObject, dal);

                    dal.CommitTransaction();
                    return(dataObject);
                }
                catch
                {
                    dal.RollbackTransaction();
                    throw;
                }
            }
            // return base.Create(dataObject);
        }
Example #29
0
    protected void btnRegisterComplaint_Click(object sender, EventArgs e)
    {

        using (ApplicationDbContext DbContext = new ApplicationDbContext())
        {
            Complainant LoggedInComplainant = DbContext.Complainants.ToList().Where(x => (x.Id == User.Identity.GetUserId())).FirstOrDefault();

            Suggestion suggestion = new Suggestion()
            {
                Department = (Grievance.GrievanceTypes)Convert.ToInt16(ddlComplaintType.SelectedValue),
                Description = txtComplaintDescription.Text,
                Complainant = LoggedInComplainant,
                DateLogged = DateTime.Now
            };

            DbContext.Suggestions.Add(suggestion);
            DbContext.SaveChanges();

            BindRepeater();

            SuccessMessage.Text = "Your suggestion has been recorded.";
            SuccessPlaceHolder.Visible = true;
        }
    }
Example #30
0
        // GET: Suggestion/Acknowledge/5
        public ActionResult Acknowledge(int?id)
        {
            if ((HttpContext.Session.GetString("Role") == null) ||
                (HttpContext.Session.GetString("Role") != "Student"))
            {
                return(RedirectToAction("Index", "Home"));
            }

            if (id == null)
            {
                TempData["ErrorMessage"] = "You are not allowed to acknowledge other student's suggestions!";
                return(RedirectToAction("Index"));
            }
            int        studentid  = Convert.ToInt32(HttpContext.Session.GetInt32("StudentID"));
            Suggestion suggestion = suggestionContext.GetSuggestionDetails(id.Value);
            StudentSuggestionViewModel suggestionVM = MapToLecturerVM(suggestion);

            if (suggestion == null || suggestion.StudentId != studentid)
            {
                TempData["ErrorMessage"] = "You are not allowed to acknowledge other student's suggestions!";
                return(RedirectToAction("StudentSuggestion"));
            }
            return(View(suggestionVM));
        }
                public List<Suggestion> SuggestKeyword(string searchText, bool fuzzy)
                {
                    var         _serviceUri = new Uri("https://myjobs.search.windows.net");
                    var _httpClient = new HttpClient();
                    _httpClient.DefaultRequestHeaders.Add("api-key", "6917F2050016ACCA313196EB37DB826D");

                    // Pass the specified suggestion text and return the fields
                    //            Uri uri = new Uri(_serviceUri, "/indexes/index1/docs/suggest?suggesterName=sg&highlightPreTag=%3Cem%3E&highlightPostTag=%3C%2Fem%3E&fuzzy=" + fuzzy + "&search=" + Uri.EscapeDataString(searchText));
                    Uri uri = new Uri(_serviceUri, "/indexes/index-flat-jobs/docs/suggest?suggesterName=suggester-keyword&$top=100&fuzzy=" + fuzzy + "&search=" + Uri.EscapeDataString(searchText));
        
        
                    HttpResponseMessage response = AzureSearchHelper.SendSearchRequest(_httpClient, HttpMethod.Get, uri);
                    AzureSearchHelper.EnsureSuccessfulSearchResponse(response);
                    List<Suggestion> suggestionList = new List<Suggestion>();
        
                    //            List<string> suggestionList = new List<string>();
        
                    foreach (var option in AzureSearchHelper.DeserializeJson<dynamic>(response.Content.ReadAsStringAsync().Result).value)
                    {
                        Suggestion suggestion = new Suggestion();
                        suggestion.id = (string)option["id"];
                        suggestion.value = "\"" + (string)option["@search.text"] + "\"";
                        //                suggestion.name = (string)option["name"];
                        //                suggestion.species = (string)option["species"];
                        //                suggestion.thumbnail = (string)option["thumbnail"];
                        suggestionList.Add(suggestion);
                    }
        
                    //            return suggestionList;$top=#
        
                    var distinctTitles = suggestionList.DistinctBy(x => x.value);
        
                    List<Suggestion> distinctList = distinctTitles.ToList();
        
                    return distinctList;
                }
Example #32
0
        public ActionResult PostSuggestion(Suggestion suggest)
        {
            int lecturerid = Convert.ToInt32(HttpContext.Session.GetString("ID"));
            List <SelectListItem> menteeList = new List <SelectListItem>(lecturerContext.GetMentees(lecturerid));

            if (menteeList.Count() == 0)
            {
                ViewData["Message"] = "You Must Have A Mentee To Post!";
                return(View());
            }
            ViewData["MenteeList"] = menteeList;
            suggest.LecturerId     = lecturerid;
            suggest.Status         = 'N';
            if (ModelState.IsValid)
            {
                suggest.SuggestionId = suggestionContext.PostSuggestion(suggest);
                ViewData["Message"]  = "Suggestion Posted Successfully";
                return(View());
            }
            else
            {
                return(View(suggest));
            }
        }
        public ContextEdge NewContextEdge(OutcomeOrSuggestion item)
        {
            Outcome outcome = item as Outcome;

            if (outcome != null)
            {
                var result = new OutcomeContextEdge {
                    Outcome = outcome
                };
                outcome.OutcomeContextEdges.Add(result);
                return(result);
            }
            Suggestion sugg = item as Suggestion;

            if (sugg != null)
            {
                var result = new SuggestionContextEdge {
                    Suggestion = sugg
                };
                sugg.SuggestionContextEdges.Add(result);
                return(result);
            }
            return(null);
        }
 public void Sugggest_3As_SuggestsRegularAndAlso3LetterMatch()
 {
     Suggestion sug = new Suggestion(@"^\w+$", "1 or more letters");
     Suggestion sugMulti = new Suggestion(@"^\w{3}$", "3 letters");
     suggest.Learn(sug);
     //don't learn the other one..
     List<Suggestion> options = suggest.Suggest("aaa");
     Assert.AreEqual(sugMulti, options[2]);
 }
Example #35
0
 public DiagnosticResult(Status status, Checkup checkup, Suggestion prescription)
     : this(status, checkup, null, prescription)
 {
 }
 public void Sugggest_2Spaces_SuggestsRegularAndAlsoSpaceSuggestion()
 {
     Suggestion sug = new Suggestion(@"^\s+$", "1 or more spaces");
     Suggestion sugMulti = new Suggestion(@"^\s{2}$", "2 spaces");
     suggest.Learn(sug);
     //don't learn the other one..
     List<Suggestion> options = suggest.Suggest("  ");
     Assert.AreEqual(sugMulti, options[2]);
 }
Example #37
0
        /// <summary>
        /// Create a set of suggestions from the results of calling the suggestion function
        /// </summary>
        /// <param name="workflowInstance">Workflow instance to operate over</param>
        /// <param name="item">Item to process</param>
        /// <param name="suggestionFunction">Suggestion generation function</param>
        /// <returns>Complete if an exact match was found, Pending if multiple suggestions created</returns>
        protected Status CreateSuggestions(
            WorkflowInstance workflowInstance,
            ServerEntity entity,
            Func <WorkflowInstance, ServerEntity, Dictionary <string, string>, Status> suggestionFunction)
        {
            // analyze the item for possible suggestions
            var    suggestions = new Dictionary <string, string>();
            Status status      = suggestionFunction.Invoke(workflowInstance, entity, suggestions);

            TraceLog.TraceDetail(String.Format("Retrieved {0} suggestions from activity {1}", suggestions.Count, Name));

            // if the function completed with an error, or without generating any data, return (this is typically a fail-fast state)
            if (status == Status.Error || suggestions.Count == 0)
            {
                return(status);
            }

            // if an "exact match" was discovered without user input, store it now and return
            if (status == Status.Complete && suggestions.Count == 1)
            {
                string s = null;
                foreach (var value in suggestions.Values)
                {
                    s = value;
                }
                StoreInstanceData(workflowInstance, ActivityVariables.LastStateData, s);
                StoreInstanceData(workflowInstance, OutputParameterName, s);
                TraceLog.TraceDetail(String.Format("Exact match {0} was found for activity {1}", s, Name));
                return(status);
            }

            // construct the group display name
            string groupDisplayName = GroupDisplayName;

            if (groupDisplayName == null)
            {
                groupDisplayName = workflowInstance.State;
            }
            else
            {
                groupDisplayName = FormatStringTemplate(workflowInstance, groupDisplayName);
            }

            // get the suggestion parent ID if available
            var parentID = GetInstanceData(workflowInstance, ActivityVariables.ParentID);

            // add suggestions received from the suggestion function
            try
            {
                int num = 0;
                foreach (var s in suggestions.Keys)
                {
                    // limit to four suggestions
                    if (num++ == 4)
                    {
                        break;
                    }

                    var sugg = new Suggestion()
                    {
                        ID                 = Guid.NewGuid(),
                        ParentID           = parentID == null ? (Guid?)null : new Guid(parentID),
                        EntityID           = entity.ID,
                        EntityType         = entity.GetType().Name,
                        WorkflowType       = workflowInstance.WorkflowType,
                        WorkflowInstanceID = workflowInstance.ID,
                        State              = workflowInstance.State,
                        SuggestionType     = SuggestionType,
                        DisplayName        = s,
                        GroupDisplayName   = groupDisplayName,
                        SortOrder          = num,
                        Value              = suggestions[s],
                        TimeSelected       = null
                    };
                    SuggestionsContext.Suggestions.Add(sugg);

                    TraceLog.TraceDetail(String.Format("Created suggestion {0} in group {1} for activity {2}", s, groupDisplayName, Name));
                }

                SuggestionsContext.SaveChanges();
                return(status);
            }
            catch (Exception ex)
            {
                TraceLog.TraceException("Activity execution failed", ex);
                return(Status.Error);
            }
        }
Example #38
0
        /// <summary>
        /// Reads input from user using hints. Commands history is supported.
        /// </summary>
        /// <param name="inputRegex"></param>
        /// <returns></returns>
        public string ReadLine(string currentDirectory, string inputRegex = ".*")
        {
            ConsoleKeyInfo input;

            _currentDirectory = currentDirectory;
            Suggestion suggestion     = null;
            var        userInput      = string.Empty;
            var        fullInput      = string.Empty;
            var        readLine       = string.Empty;
            var        wasUserInput   = false;
            var        cursorPosition = new ConsoleCursorPosition(currentDirectory.Length + ConsoleUtils.Prompt.Length - 1, Console.CursorTop, Console.WindowWidth);

            ClearConsoleLines(cursorPosition.StartTop, cursorPosition.Top);
            while ((input = Console.ReadKey()).Key != ConsoleKey.Enter)
            {
                var writeSugestionToConsole = false;
                int positionToDelete;
                if (_previousPressedKey == ConsoleKey.Tab && input.Key != ConsoleKey.Tab)
                {
                    _suggestionsForUserInput = null;
                    suggestion = null;
                }

                switch (input.Key)
                {
                case ConsoleKey.Delete:
                    positionToDelete = cursorPosition.InputLength;
                    if (positionToDelete >= 0 && positionToDelete < userInput.Length)
                    {
                        if (_currentDirectory.Length > cursorPosition.Left - cursorPosition.InputLength)
                        {
                            cursorPosition--;
                        }

                        userInput = userInput.Any() ? userInput.Remove(positionToDelete, 1) : string.Empty;
                    }

                    wasUserInput = !string.IsNullOrWhiteSpace(userInput);
                    UpdateSuggestionsForUserInput(userInput);
                    suggestion = GetFirstSuggestion();
                    break;

                case ConsoleKey.Backspace:
                    positionToDelete = cursorPosition.InputLength - 1;
                    if (positionToDelete >= 0 && positionToDelete < userInput.Length)
                    {
                        userInput = userInput.Any() ? userInput.Remove(positionToDelete, 1) : string.Empty;
                        cursorPosition--;
                    }

                    if (cursorPosition.InputLength < 0)
                    {
                        cursorPosition = cursorPosition.SetLength(0);
                    }

                    wasUserInput = !string.IsNullOrWhiteSpace(userInput);
                    UpdateSuggestionsForUserInput(userInput);
                    suggestion = GetFirstSuggestion();
                    break;

                case ConsoleKey.Tab:
                    if (_previousPressedKey == ConsoleKey.Tab)
                    {
                        suggestion = GetNextSuggestion();
                        if (suggestion != null)
                        {
                            writeSugestionToConsole = true;
                            userInput = suggestion.Value + ' ';
                        }
                    }
                    else
                    {
                        if (suggestion != null)
                        {
                            writeSugestionToConsole = true;
                            userInput = suggestion.Value + ' ';
                            ////UpdateSuggestionsForUserInput(userInput);
                            suggestion = GetFirstSuggestion();
                            var tmp = fullInput.LastIndexOf(" ");

                            if (fullInput.EndsWith("="))
                            {
                                cursorPosition = cursorPosition.SetLength(fullInput.Length);
                            }
                            else if (tmp == -1)
                            {
                                cursorPosition = cursorPosition.SetLength(userInput.Length);
                            }
                            else
                            {
                                cursorPosition = cursorPosition.SetLength(tmp + userInput.Length);
                            }
                        }
                    }

                    break;

                case ConsoleKey.Spacebar:
                    userInput    = userInput.Insert(cursorPosition.InputLength, " ");
                    wasUserInput = true;
                    cursorPosition++;

                    if (userInput.StartsWith(InternalCommands.Cd))
                    {
                        UpdateDirectorySuggestionsForUserInput(userInput);
                        suggestion = GetFirstSuggestion();
                    }
                    else
                    {
                        _suggestionsForUserInput = null;
                        suggestion = null;
                    }

                    break;

                case ConsoleKey.UpArrow:
                    if (!wasUserInput)
                    {
                        userInput      = GetPreviousCommandFromHistory();
                        cursorPosition = cursorPosition.SetLength(userInput.Length);
                    }
                    else
                    {
                        suggestion = GetPreviousSuggestion();
                    }

                    break;

                case ConsoleKey.DownArrow:
                    if (!wasUserInput)
                    {
                        userInput      = GetNextCommandFromHistory();
                        cursorPosition = cursorPosition.SetLength(userInput.Length);
                    }
                    else
                    {
                        suggestion = GetNextSuggestion();
                    }

                    break;

                case ConsoleKey.LeftArrow:
                    if (cursorPosition.InputLength > 0)
                    {
                        cursorPosition--;
                    }

                    break;

                case ConsoleKey.RightArrow:
                    if (cursorPosition.InputLength < userInput.Length)
                    {
                        cursorPosition++;
                    }

                    break;

                case ConsoleKey.Home:
                    cursorPosition = cursorPosition.SetLength(0);
                    break;

                case ConsoleKey.End:
                    cursorPosition = cursorPosition.SetLength(userInput.Length);
                    break;

                case ConsoleKey.F1:
                case ConsoleKey.F2:
                case ConsoleKey.F3:
                case ConsoleKey.F4:
                case ConsoleKey.F5:
                case ConsoleKey.F6:
                case ConsoleKey.F7:
                case ConsoleKey.F8:
                case ConsoleKey.F9:
                case ConsoleKey.F10:
                case ConsoleKey.F11:
                case ConsoleKey.F12:
                    break;

                default:
                    if (Regex.IsMatch(input.KeyChar.ToString(), inputRegex))
                    {
                        cursorPosition++;
                        userInput = userInput.Insert(cursorPosition.InputLength - 1,
                                                     input.KeyChar.ToString());
                    }

                    wasUserInput = true;

                    if (userInput.StartsWith(InternalCommands.Cd))
                    {
                        UpdateDirectorySuggestionsForUserInput(userInput);
                    }
                    else
                    {
                        UpdateSuggestionsForUserInput(userInput);
                    }

                    suggestion = GetFirstSuggestion();
                    break;
                }

                readLine = suggestion != null ? suggestion.Value : userInput.TrimEnd(' ');

                ClearConsoleLines(cursorPosition.StartTop, cursorPosition.Top);
                var li = fullInput.TrimEnd().LastIndexOf(" ");
                if (li == -1 && !fullInput.StartsWith(InternalCommands.Cd, StringComparison.OrdinalIgnoreCase))
                {
                    if (input.Key == ConsoleKey.Tab && _previousPressedKey == ConsoleKey.Tab && suggestion != null)
                    {
                        fullInput      = userInput;
                        cursorPosition = cursorPosition.SetLength(fullInput.Length);
                        ConsoleUtils.Write(fullInput, ConsoleColor.Green);
                    }
                    else
                    {
                        ConsoleUtils.Write(userInput, ConsoleColor.Green);
                        fullInput = userInput;
                    }
                }
                else
                {
                    if (!writeSugestionToConsole)
                    {
                        ConsoleUtils.Write(userInput, ConsoleColor.Green);
                        fullInput = userInput;
                    }
                    else
                    {
                        userInput = WriteSugestionAsUserInput(userInput, suggestion, li, ref fullInput, ref cursorPosition);
                    }
                }

                if (userInput.Any())
                {
                    if (suggestion != null && suggestion.Value != userInput && writeSugestionToConsole == false)
                    {
                        WriteSuggestion(suggestion);
                        WriteOnBottomLine(suggestion.Help);
                        _lastSuggestion = suggestion;
                    }
                    else
                    {
                        var splitedUserInput = userInput.Split(' ');
                        var toCheck          = splitedUserInput.Last().Split('=').First();
                        if (_lastSuggestion != null && toCheck.Equals(_lastSuggestion.Value))
                        {
                            WriteOnBottomLine(_lastSuggestion.Help);
                        }
                        else
                        {
                            WriteOnBottomLine(string.Empty);
                        }
                    }
                }
                else
                {
                    WriteOnBottomLine(string.Empty);
                }

                Console.CursorLeft  = cursorPosition.Left;
                Console.CursorTop   = cursorPosition.Top;
                _previousPressedKey = input.Key;
            }

            Console.WriteLine(string.Empty);
            AddCommandToHistory(fullInput);
            return(fullInput);
        }
Example #39
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="input"></param>
        /// <param name="suggestions"></param>
        /// <returns></returns>
        Suggestion AutoCompleteCommand(string input, string[] args, string commandName)
        {
            var suggestion = new Suggestion(input);

            var cmd          = GetCommand(commandName);
            var parser       = GetParser(commandName);
            var numRequired  = parser.RequiredUsageHelp.Count;
            var numOptions   = parser.OptionalUsageHelp.Count;
            var tailingSpace = input.Last() == ' ';

            //	add fictional empty argument for more clear suggestion:
            if (tailingSpace)
            {
                Array.Resize <string>(ref args, args.Length + 1);
                args[args.Length - 1] = "";
            }


            //	command without tailing space - add space:
            if (args.Length == 1)
            {
                suggestion.CommandLine = ArgsToString(args) + " ";
                DetailedCommandHelp(suggestion, parser, commandName);
                return(suggestion);
            }

            //	store last argument :
            var lastArg = args.Last();

            //	question?
            if (lastArg == "?")
            {
                DetailedCommandHelp(suggestion, parser, commandName);
                return(suggestion);
            }


            //	add short help :
            AddCommandSyntax(suggestion, parser, commandName);

            if (lastArg.StartsWith("/"))
            {
                #region OPTIONS
                var name  = lastArg.Substring(1);
                var index = name.IndexOf(':');

                if (index != -1)
                {
                    name = name.Substring(0, index);
                }

                var candidates = new string[0];
                var options    = parser.OptionalUsageHelp;
                CommandLineParser.ArgumentInfo pi;

                if (options.TryGetValue(name, out pi))
                {
                    if (pi.ArgumentType == typeof(bool))
                    {
                        suggestion.CommandLine = ArgsToString(args) + " ";
                        return(suggestion);
                    }
                    else
                    {
                        if (index == -1)
                        {
                            suggestion.CommandLine = ArgsToString(args) + ":";
                            return(suggestion);
                        }
                        else
                        {
                            var value = lastArg.Substring(index + 2);
                            candidates = cmd.Suggest(pi.ArgumentType, name).ToArray();
                            value      = LongestCommon(value, ref candidates);
                            suggestion.AddRange(candidates);
                            suggestion.CommandLine = ArgsToString(args, "/" + name + ":" + value);
                            return(suggestion);
                        }
                    }
                }

                candidates = options
                             .Select(p => "/" + p.Key)
                             .OrderBy(n => n).ToArray();

                lastArg = LongestCommon(lastArg, ref candidates);

                suggestion.AddRange(candidates);

                suggestion.CommandLine = ArgsToString(args, lastArg);
                #endregion
            }
            else
            {
                #region REQUIRED
                var candidates   = new string[0];
                int currentIndex = Math.Max(0, args.Skip(1).Count(arg => !arg.StartsWith("/"))) - 1;

                if (currentIndex < numRequired)
                {
                    var pi = parser.RequiredUsageHelp[currentIndex];

                    var name = pi.Name;
                    var type = pi.ArgumentType;

                    candidates = cmd.Suggest(type, name).ToArray();

                    var longest = LongestCommon(lastArg, ref candidates);

                    suggestion.AddRange(candidates);

                    var postFix = (lastArg == "" || candidates.Length == 1) ? " " : "";

                    suggestion.CommandLine = ArgsToString(args, longest ?? lastArg) + postFix;
                }
                #endregion
            }

            return(suggestion);
        }
        public void Sugggest_ScopeWithNameAndGroupedSuggestion_DoesNotConvertsUnneedlessly()
        {
            Suggestion nonGroupedSuggestions = new Suggestion(".", "anything", 1000);
            Scope root = new Scope("abc", "RootName");
            Scope inner = root.DefineInnerScope(1, 1);
            inner.Name="Inner";

            GroupedSuggestionDecorator grouped = new GroupedSuggestionDecorator(nonGroupedSuggestions,inner);
            inner.Suggestions.Add(grouped);

            Suggestion suggestion = suggest.Suggest(root)[0];
            Assert.AreEqual(@"(?<RootName>^a$(?<Inner>.)^c$)", suggestion.RegexText);
        }
 public IActionResult Edit(Suggestion suggestion)
 {
     suggestionRepo.Edit(suggestion);
     return(RedirectToAction("Index"));
 }
 public void Sugggest_LearnCalledWithTwoMatches_TwoSuggestionsFound()
 {
     Suggestion s1 = new Suggestion(@"a", "explicit match a");
     Suggestion s2 = new Suggestion(@".", "anything");
     suggest.Learn(s1);
     suggest.Learn(s2);
     List<Suggestion> options = suggest.Suggest("a");
     Assert.AreSame(s2, options[1]);
 }
 public void Sugggest_MultipleLearns2Differentletters_SuggestsRegularAndMultipleLetters_ButNotSameLetterMultipleMatch()
 {
     Suggestion sug = new Suggestion(@"^\w+$", "1 or more letters");
     Suggestion sug2 = new Suggestion(@"^\d+$", "1 or more digitis");
     suggest.Learn(sug, sug2);
     List<Suggestion> options = suggest.Suggest("ab");
     Assert.AreEqual(3, options.Count);
 }
        public void Sugggest_LearnCalledWithTwoMatchesAndOneNoMatch_TwoSuggestionsFound()
        {
            Suggestion s1 = new Suggestion(@"a", "explicit match a");
            Suggestion s2 = new Suggestion(@".", "anything");
            Suggestion s3 = new Suggestion(@"b", "explicit match a");

            suggest.Learn(s1, s2, s3);
            List<Suggestion> options = suggest.Suggest("a");
            Assert.AreEqual(2, options.Count);
        }
 public void Sugggest_LearnCalledWithMatch_OneSuggestionFound()
 {
     Suggestion s = new Suggestion(@"a", "explicit match a");
     suggest.Learn(s);
     List<Suggestion> options = suggest.Suggest("a");
     Assert.AreSame(s, options[0]);
 }
        public void Sugggest_4spaces_SuggestsRegularAndAlso3SpaceMatch()
        {
            Suggestion sug = new Suggestion(@"^\s+$", "1 or more spaces");
            suggest.Learn(sug);
            List<Suggestion> options = suggest.Suggest("    ");

            Suggestion sugMulti = new Suggestion(@"^\s{4}$", "4 spaces");
            Assert.AreEqual(sugMulti, options[2]);
        }
Example #47
0
 public DiagnosticResult(Status status, Checkup checkup, string message = null, Suggestion prescription = null)
 {
     Status     = status;
     Checkup    = checkup;
     Message    = message;
     Suggestion = prescription;
 }
        public void Sugggest_ScopeWithNameAndNonGroupedSuggestion_ConvertsToGrouped()
        {
            Suggestion nonGroupedSuggestions = new Suggestion(".", "anything", 1000);

            Scope root = new Scope("abc", "RootName");
            Scope inner = root.DefineInnerScope(1, 1);
            inner.Name="Inner";
            inner.Suggestions.Add(nonGroupedSuggestions);
            Suggestion suggestion = suggest.Suggest(root)[0];
            Assert.AreEqual(@"(?<RootName>^a$(?<Inner>.)^c$)", suggestion.RegexText);
        }
 public IActionResult Create(Suggestion suggestion)
 {
     suggestionRepo.Save(suggestion);
     return(RedirectToAction("Index"));
 }
        public void UseGroupsForUnNamedScopes_GroupedSuggestionExists2ndPass_DoesNotNestGroupInItselfLeftNameworks()
        {
            Scope root = new Scope("abc");
            Scope inner = root.DefineInnerScope(1, 1);
            inner.Name = "Inner";
            Suggestion simple = new Suggestion(".", "anything");
            UnNamedGroupedSuggestionDecorator grouped = new UnNamedGroupedSuggestionDecorator(simple,inner);
            inner.Suggestions.Add(grouped);

            suggest.UseGroupsForUnnamedScopes = true;
            Suggestion suggestion = suggest.Suggest(root)[0];

            root.InnerLeftScope.Name = "left";
            suggestion = suggest.Suggest(root)[0];
            Assert.AreEqual(@"(?<Root>(?<left>^a$)(?<Inner>.)(^c$))",suggestion.RegexText);
        }
        //Delete a Suggestion
        public IActionResult Delete(int id)
        {
            Suggestion thisSuggestion = suggestionRepo.Suggestions.FirstOrDefault(suggestion => suggestion.SuggestionId == id);

            return(View(thisSuggestion));
        }
        public void UseGroupsUnNamedScopes_ScopeWithNoNameAndNonGroupedSuggestion_ConvertsToGrouped()
        {
            suggest.UseGroupsForUnnamedScopes = true;
            Suggestion nonGroupedSuggestions = new Suggestion(".", "anything", 1000);

            Scope root = new Scope("abc");
            Scope inner = root.DefineInnerScope(1, 1);

            inner.Suggestions.Add(nonGroupedSuggestions);
            Suggestion suggestion = suggest.Suggest(root)[0];
            Assert.AreEqual(@"((^a$)(.)(^c$))", suggestion.RegexText);
        }
 public int AddSuggestion(Suggestion objSuggestions)
 {
     db.Suggestions.Add(objSuggestions);
     return(db.SaveChanges());
 }
        public void Sugggest_31s_SuggestsRegularAndAlso31Match()
        {
            Suggestion sug = new Suggestion(@"^\d+$", "1 or more digits");
            suggest.Learn(sug);
            List<Suggestion> options = suggest.Suggest("111");

            Suggestion sugMulti = new Suggestion(@"^1{3}$", "3 '1' digits");
            Assert.AreEqual(sugMulti, options[3]);
        }
 public SuggestionRemovedMessage(Suggestion suggestion)
 {
     Suggestion = suggestion;
 }
 private Recorded <Notification <Suggestion> > createRecorded(int ticks, Suggestion suggestion)
 => new Recorded <Notification <Suggestion> >(ticks, Notification.CreateOnNext(suggestion));
        private void addSuggestion(Suggestion suggestion)
        {
            Suggestions.Add(suggestion);

            RaisePropertyChanged();
        }
Example #58
0
 void IAdvisor.Learn(Suggestion suggestion)
 {
     throw new Exception("The method or operation is not implemented.");
 }
Example #59
0
 public ActionResult Post(Suggestion a)
 {
     _db.Add(a);
     return(Ok());
 }
        public void Sugggest_3As_SuggestsRegularAndAlso3AMatch()
        {
            Suggestion sug = new Suggestion(@"^\w+$", "1 or more letters");
            suggest.Learn(sug);
            List<Suggestion> options = suggest.Suggest("aaa");

            Suggestion sugMulti = new Suggestion(@"^a{3}$", "3 'a' letters");
            Assert.AreEqual(sugMulti, options[3]);
        }