Esempio n. 1
0
        public string Send(string thought, int top, int left, int level)
        {
            AnaWeenEntities entities = new AnaWeenEntities();
            var user = entities.Members.First(u => u.Login == User.Identity.Name || u.Mail == User.Identity.Name);
            if (user != null)
            {
                var lexs = thought.Split(' ').Where(l => l.Length > 0 && l[0] == '#');
                var newThought = new Thought() { Text = thought, Top = top, left = left, Level = level };
                foreach (var lex in lexs)
                {
                    if (!entities.Lexicons.Any(l => l.Value == lex))
                    {
                        newThought.Lexicon.Add(new Lexicon() { Value = lex });
                    }
                    else
                    {
                        newThought.Lexicon.Add(entities.Lexicons.FirstOrDefault(l => l.Value == lex));
                    }
                }
                user.Thoughts.Add(newThought);
                entities.SaveChanges();
                return thought;
            }
            else
            {
                return "Error";
            }

        }
Esempio n. 2
0
 /// <summary>
 /// Create a new Thought object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="text">Initial value of the Text property.</param>
 public static Thought CreateThought(global::System.Int32 id, global::System.String text)
 {
     Thought thought = new Thought();
     thought.Id = id;
     thought.Text = text;
     return thought;
 }
Esempio n. 3
0
 /// <summary>
 /// Deprecated Method for adding a new object to the Thoughts EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToThoughts(Thought thought)
 {
     base.AddObject("Thoughts", thought);
 }