Пример #1
0
        private Dictionary <string, object> GetBeardParameters()
        {
            UserProfile = Db.FindUserProfile(new UserProfile2Discriminator {
                Filter = x => x.UserId == UserId, Take = 1
            }, null, null).First().UserProfile2;

            var ret = new Dictionary <string, object>();

            ret.Add("firstName", UserProfile.FirstName);
            ret.Add("lastName", UserProfile.LastName);
            ret.Add("photo", string.IsNullOrEmpty(UserProfile.Photo) ? incognitoPhoto : UserProfile.Photo);
            if (!string.IsNullOrEmpty(UserProfile.PersonalId))
            {
                string base64String;
                using (var img = Zen.Barcode.BarcodeDrawFactory.Code39WithoutChecksum.Draw(UserProfile.PersonalId, 40)) {
                    using (MemoryStream m = new MemoryStream())
                    {
                        img.Save(m, System.Drawing.Imaging.ImageFormat.Png);
                        byte[] imageBytes = m.ToArray();

                        base64String = Convert.ToBase64String(imageBytes);
                    }
                    ret.Add("personalid", $"data:image/png;base64,{base64String}");
                }
            }
            return(ret);
        }
 public static void CopyTo(this IUserProfile2 from, IUserProfile2 to, bool allowDefaultValues = true)
 {
     (from as IUserProfile).CopyTo(to, allowDefaultValues);
     if (allowDefaultValues || !string.IsNullOrEmpty(from.Photo))
     {
         to.Photo = from.Photo;
     }
     if (allowDefaultValues || !string.IsNullOrEmpty(from.PersonalId))
     {
         to.PersonalId = from.PersonalId;
     }
 }