private UserInfoEx CreateUserInfoEx(USER_INFO info, bool full)
 {
     var result = new UserInfoEx();
     result.Id = info.Id;
     result.AvatarBigFileName = info.AvatarBig;
     // if full reading is enabled, then hash codes will be set automatically with setting data
     if (info.FILE_BIG != null)
     {
         if (full)
             result.AvatarBigData = info.FILE_BIG.Data;
         else
             result.AvatarBigHashCode = info.FILE_BIG.HashCode ?? UserInfoEx.ComputeHash(result.AvatarBigData);
     }
     result.AvatarSmallFileName = info.AvatarSmall;
     if (info.FILE_SMALL != null)
     {
         if (full)
             result.AvatarSmallData = info.FILE_SMALL.Data;
         else
             result.AvatarSmallHashCode = info.FILE_SMALL.HashCode ?? UserInfoEx.ComputeHash(result.AvatarSmallData);
     }
     result.AboutFileName = info.About;
     if (info.FILE_ABOUT != null)
     {
         if (full)
             result.AboutData = info.FILE_ABOUT.Data;
         else
             result.AboutHashCode = info.FILE_ABOUT.HashCode ?? UserInfoEx.ComputeHash(result.AboutData);
     }
     result.Contacts = info.Contacts;
     return result;
 }
 // если файловые данные (аватары, текст) не меняются, то передается null и действительная хеш-сумма
 public UserInfoEx SetUserInfo(UserInfoEx info)
 {
     UserInfoEx result;
     using (var context = DatabaseContext.Instance.Make())
     {
         try
         {
             var dbUserInfo = context.USER_INFO.Find(info.Id);
             var userInfoAdded = false;
             var fileChanged = false;
             if (dbUserInfo == null)
             {
                 dbUserInfo = new USER_INFO();
                 dbUserInfo.Id = info.Id;
                 userInfoAdded = true;
             }
             // big avatar
             if (dbUserInfo.AvatarBig == null)
             {
                 if (info.AvatarBig != null) // insert
                     dbUserInfo.AvatarBig = context.FILE.Add(CreateBitmap(info.AvatarBig)).Name;
             }
             else if (dbUserInfo.FILE_BIG.HashCode != info.AvatarBigHashCode)
                 if (info.AvatarBig == null) // delete
                 {
                     context.FILE.Remove(dbUserInfo.FILE_BIG);
                     dbUserInfo.AvatarBig = null;
                 }
                 else // update
                 {
                     if (UpdateBitmap(dbUserInfo.FILE_BIG, info.AvatarBig))
                         fileChanged = true;
                 }
             // small avatar
             if (dbUserInfo.AvatarSmall == null)
             {
                 if (info.AvatarSmall != null) // insert
                     dbUserInfo.AvatarSmall = context.FILE.Add(CreateBitmap(info.AvatarSmall)).Name;
             }
             else if (dbUserInfo.FILE_SMALL.HashCode != info.AvatarSmallHashCode)
                 if (info.AvatarSmall == null) // delete
                 {
                     context.FILE.Remove(dbUserInfo.FILE_SMALL);
                     dbUserInfo.AvatarSmall = null;
                 }
                 else // update
                 {
                     if (UpdateBitmap(dbUserInfo.FILE_SMALL, info.AvatarSmall))
                         fileChanged = true;
                 }
             // about
             if (dbUserInfo.About == null)
             {
                 if (info.About != null) // insert
                     dbUserInfo.About = context.FILE.Add(CreateText(info.About)).Name;
             }
             else if (dbUserInfo.FILE_ABOUT.HashCode != info.AboutHashCode)
                 if (info.About == null) // delete
                 {
                     context.FILE.Remove(dbUserInfo.FILE_ABOUT);
                     dbUserInfo.About = null;
                 }
                 else // update
                 {
                     if (UpdateText(dbUserInfo.FILE_ABOUT, info.About))
                         fileChanged = true;
                 }
             if(fileChanged)
                 context.SaveChanges();
             dbUserInfo.Contacts = info.Contacts;
             if (userInfoAdded)
                 context.USER_INFO.Add(dbUserInfo);
             context.SaveChanges();
             result = CreateUserInfoEx(dbUserInfo, false);
         }
         catch (Exception ex)
         {
             Logger.Error("AccountEfficiencyCache.SetUserInfo", ex);
             return null;
         }
     }
     return result;
 }