Esempio n. 1
0
 /// <summary>
 /// Создает объект из коллекции пар ключ-значение
 /// </summary>
 /// <returns>Запись гостевой книги</returns>
 /// <param name="pairs">Pairs.</param>
 public static GuestbookEntry FromDictionary(Dictionary<string, string> pairs)
 {
     GuestbookEntry entry = new GuestbookEntry ();
     if (pairs.ContainsKey("user")) entry.User = pairs["user"];
     if (pairs.ContainsKey("message")) entry.Message = pairs["message"];
     return entry;
 }
 /// <summary>
 /// Сохраняет запись
 /// </summary>
 /// <param name="entry">Entry.</param>
 protected override void SaveEntry(GuestbookEntry entry)
 {
     lock (_serializer)
     {
         _guestbook.Entries.Add(entry);
         _guestbookChanged.Set ();
     }
 }
 /// <summary>
 /// Сохраняет запись
 /// </summary>
 /// <param name="entry">Entry.</param>
 protected override void SaveEntry(GuestbookEntry entry)
 {
     using (var db = new DbManager())
     {
         var dbEntry = new DbGuestbookEntry ();
         dbEntry.Message = entry.Message;
         var dbUser = db.GetTable<DbGuestbookUser>().SingleOrDefault (u => u.Name == entry.User);
         if (dbUser == null)
         {
             dbUser = new DbGuestbookUser { Name = entry.User };
             dbUser.Id = Convert.ToInt32(db.InsertWithIdentity (dbUser));
         }
         dbEntry.UserId = dbUser.Id;
         dbEntry.Id = Convert.ToInt32(db.InsertWithIdentity(dbEntry));
     }
 }
Esempio n. 4
0
 /// <summary>
 /// Сохраняет запись
 /// </summary>
 /// <param name="entry">Entry.</param>
 protected abstract void SaveEntry(GuestbookEntry entry);