Пример #1
0
        public void BuildMessage_PhotoJSON_TelegramPhotoMessage()
        {
            var expected = new PhotoMessage
            {
                From    = _user,
                Photo   = _photo,
                Caption = _caption
            };

            AttachGeneralProperties(expected);
            var actual           = MessageBuilder.BuildMessage <PhotoMessage>(_messageToken);
            var compareLogic     = new CompareLogic(_config);
            var comparisonResult = compareLogic.Compare(expected, actual);

            Assert.IsTrue(comparisonResult.AreEqual, comparisonResult.DifferencesString);
        }
Пример #2
0
        public Response SendPhoto(PhotoMessage message)
        {
            string url = baseUrl + "sendphoto";

            MultipartFormDataContent multiContent = new MultipartFormDataContent
            {
                { new StringContent(message.ChatId.ToString()), "chat_id" },
                { new StringContent(message.Caption), "caption" },
            };

            if (message.ReplyMarkup != null)
            {
                multiContent.Add(new StringContent(Utils.Serialize(message.ReplyMarkup)), "reply_markup");
            }


            if (message.ReplyToMessageId != null)
            {
                multiContent.Add(new StringContent("reply_to_message_id"), message.ReplyToMessageId?.ToString());
            }

            ByteArrayContent imageContent = new ByteArrayContent(message.Photo);

            imageContent.Headers.ContentType = new MediaTypeHeaderValue("image/png");

            multiContent.Add(imageContent, "photo");


            HttpResponseMessage response = client.PostAsync(url, multiContent).Result;

            if (response.StatusCode == System.Net.HttpStatusCode.OK)
            {
                Response result = Utils.Deserialize <Response>(response.Content.ReadAsStringAsync().Result);
                return(result);
            }


            return(new Response());
        }
Пример #3
0
        public static async Task <string> GetImageUrl(string breed)
        {
            /// TODO : GetImageUrl()
            /// TODO : Compléter le modèle manquant
            string photoBreed = breed;
            string url        = $"https://dog.ceo/api/breed" + "/" + photoBreed + "/images/random";

            using (HttpResponseMessage response = await ApiHelper.ApiClient.GetAsync(url))
            {
                if (response.IsSuccessStatusCode)
                {
                    PhotoMessage urlPhoto = new PhotoMessage();
                    var          photoUrl = await response.Content.ReadAsStringAsync();

                    urlPhoto = JsonConvert.DeserializeObject <PhotoMessage>(photoUrl);
                    return(urlPhoto.message);
                }
                else
                {
                    throw new Exception(response.ReasonPhrase);
                }
            }
        }
Пример #4
0
        /// <summary>
        /// Invoked when the attachment icon is clicked.
        /// </summary>
        /// <param name="obj">The object</param>
        private async void AttachmentClicked(object obj)
        {
            int userid = Preferences.Get("UserID", 0);

            if (!await JobMePermissions.GalleryPermission())
            {
                return;
            }
            var options = new PickMediaOptions();

            options.CompressionQuality = 50;

            var photo = await CrossMedia.Current.PickPhotoAsync(options);

            if (photo != null)
            {
                var ext = photo.Path.Split('.').Last();

                var stream = photo.GetStreamWithImageRotatedForExternalStorage();

                var bytes = ImageHelper.ReadFully(stream);

                var base64Photo = Convert.ToBase64String(bytes);

                string myfoto = base64Photo;

                string fname = Path.GetFileName(photo.Path);

                string To = string.Empty;
                //mensaje para enviar
                var message = new PhotoMessage(ProfileName)
                {
                    Base64Photo = base64Photo,
                    FileEnding  = fname,
                    Recipient   = ChatDetail.ContactID.ToString(),
                    Avatar      = userid.ToString(),
                    Color       = ChatDetail.IDPosition.ToString(),
                };
                //mensaje para mostrar
                Models.Chat.ChatMessage msg = new JobMe.Models.Chat.ChatMessage()
                {
                    Time        = DateTime.Now,
                    ContactID   = ChatDetail.ContactID,
                    UserID      = ChatDetail.UserID,
                    IDPosition  = ChatDetail.IDPosition,
                    IsReceived  = false,
                    Base64Photo = photo.Path,
                    ImageUrl    = EndPoint.BLOB_ENDPOINT + fname,
                    IsImage     = true
                };

                //Verifica que este conectado al hub
                if (!App.ChatService1.IsConnected)
                {
                    App.ChatService1 = new TheChat.Core.Services.ChatService();

                    if (Preferences.Get("UserID", 0) > 0)
                    {
                        await App.ChatService1.InitAsync(Preferences.Get("UserID", 0).ToString());
                    }
                }

                //Este es el mensaje que se envia al hub
                await App.ChatService1.SendMessageAsync(message);

                //Este mensaje es el que se agrega a la lista
                ChatMessageInfo.Add(msg);

                if (Preferences.Get("UserType", 0) == 1) //Employee
                {
                    Task.Run(() => Services.PushNotifications.PushServices.SendPushAsync(ChatDetail.ContactID, Preferences.Get("Name", string.Empty), "📷 Imagen", "chat"));
                }
                else
                {
                    Task.Run(() => Services.PushNotifications.PushServices.SendPushAsync(ChatDetail.ContactID, Preferences.Get("Company", string.Empty), "📷 Imagen", "chat"));
                }

                //Ocultar el teclado en ios
                MessagingCenter.Send <ChatMessageViewModel, string>(this, "FocusKeyboardStatus", "nada");

                //Esto es para agregarlo a la base de datos
                await Services.Chat.ChatService.AddMessageAsync(msg);
            }
        }
Пример #5
0
        /// <summary>
        /// Invoked when the camera icon is clicked.
        /// </summary>
        /// <param name="obj">The object</param>
        private async void CameraClicked(object obj)
        {
            try
            {
                int userid = Preferences.Get("UserID", 0);

                if (!await JobMePermissions.CameraPermission())
                {
                    return;
                }
                var mediaOptions = new StoreCameraMediaOptions()
                {
                    SaveToAlbum        = false,
                    Directory          = "Sample",
                    PhotoSize          = Device.RuntimePlatform == Device.Android?PhotoSize.Full: PhotoSize.Medium,
                    DefaultCamera      = Plugin.Media.Abstractions.CameraDevice.Front,
                    RotateImage        = false,
                    CompressionQuality = 80,
                    AllowCropping      = true,
                    SaveMetaData       = false,
                };
                //options.CompressionQuality = 50;

                var photo = await CrossMedia.Current.TakePhotoAsync(mediaOptions);

                if (photo != null)
                {
                    var ext = photo.Path.Split('.').Last();

                    var stream = photo.GetStreamWithImageRotatedForExternalStorage();

                    var bytes = ImageHelper.ReadFully(stream);

                    var base64Photo = Convert.ToBase64String(bytes);

                    string myfoto = base64Photo;

                    string fname = Path.GetFileName(photo.Path);

                    string To = string.Empty;
                    //mensaje para enviar
                    var message = new PhotoMessage(ProfileName)
                    {
                        Base64Photo = base64Photo,
                        FileEnding  = fname,
                        Recipient   = ChatDetail.ContactID.ToString(),
                        Avatar      = userid.ToString(),
                        Color       = ChatDetail.IDPosition.ToString(),
                    };
                    //mensaje para mostrar
                    JobMe.Models.Chat.ChatMessage msg = new JobMe.Models.Chat.ChatMessage()
                    {
                        Time        = DateTime.Now,
                        ContactID   = ChatDetail.ContactID,
                        UserID      = ChatDetail.UserID,
                        IDPosition  = ChatDetail.IDPosition,
                        IsReceived  = false,
                        Base64Photo = photo.Path,
                        ImageUrl    = EndPoint.BLOB_ENDPOINT + fname,
                        IsImage     = true
                    };

                    //Este mensaje es el que se agrega a la lista
                    ChatMessageInfo.Add(msg);

                    //Verifica que este conectado al hub
                    if (!App.ChatService1.IsConnected)
                    {
                        App.ChatService1 = new TheChat.Core.Services.ChatService();

                        if (Preferences.Get("UserID", 0) > 0)
                        {
                            await App.ChatService1.InitAsync(Preferences.Get("UserID", 0).ToString());
                        }
                    }

                    //Este es el mensaje que se envia al hub
                    await App.ChatService1.SendMessageAsync(message);



                    if (Preferences.Get("UserType", 0) == 1) //Employee
                    {
                        Task.Run(() => Services.PushNotifications.PushServices.SendPushAsync(ChatDetail.ContactID, Preferences.Get("Name", string.Empty), "📷 Imagen", "chat"));
                    }
                    else
                    {
                        Task.Run(() => Services.PushNotifications.PushServices.SendPushAsync(ChatDetail.ContactID, Preferences.Get("Company", string.Empty), "📷 Imagen", "chat"));
                    }

                    //Esto es para agregarlo a la base de datos
                    await Services.Chat.ChatService.AddMessageAsync(msg);

                    //Ocultar el teclado en ios
                    MessagingCenter.Send <ChatMessageViewModel, string>(this, "FocusKeyboardStatus", "nada");
                }

                // UserDialogs.Instance.HideLoading();
            }
            catch (Exception ex)
            {
                await App.Current.MainPage.DisplayAlert("JobMe", ex.Message, "ok");

                //throw;
            }
        }
Пример #6
0
        private async void SendFileClicked(object obj)
        {
            string[] fileTypes;

            try
            {
                var status = await Permissions.CheckStatusAsync <Permissions.StorageRead>();

                if (status != PermissionStatus.Granted)
                {
                    status = await Permissions.RequestAsync <Permissions.StorageRead>();
                }

                if (status == PermissionStatus.Granted)
                {
                    var pickedFile = await Plugin.FilePicker.CrossFilePicker.Current.PickFile();

                    if (pickedFile != null)
                    {
                        var stream = pickedFile.GetStream();

                        var bytes = ImageHelper.ReadFully(stream);

                        var base64Photo = Convert.ToBase64String(bytes);

                        string myfoto = base64Photo;

                        string fname = pickedFile.FileName;

                        //mensaje para enviar
                        var message = new PhotoMessage(ProfileName)
                        {
                            Base64Photo = base64Photo,
                            FileEnding  = fname,
                            Recipient   = ChatDetail.ContactID.ToString(),
                            IsFile      = true,
                            Avatar      = ChatDetail.UserID.ToString(),
                            Color       = ChatDetail.IDPosition.ToString(),
                        };
                        //mensaje para mostrar
                        JobMe.Models.Chat.ChatMessage msg = new JobMe.Models.Chat.ChatMessage()
                        {
                            Time       = DateTime.Now,
                            ContactID  = ChatDetail.ContactID,
                            UserID     = ChatDetail.UserID,
                            IDPosition = ChatDetail.IDPosition,
                            IsReceived = false,
                            IsFile     = true,
                            Message    = fname,
                        };

                        //Verifica que este conectado al hub
                        if (!App.ChatService1.IsConnected)
                        {
                            App.ChatService1 = new TheChat.Core.Services.ChatService();

                            if (Preferences.Get("UserID", 0) > 0)
                            {
                                await App.ChatService1.InitAsync(Preferences.Get("UserID", 0).ToString());
                            }
                        }

                        //Este mensaje es el que se agrega a la lista
                        ChatMessageInfo.Add(msg);

                        //Este es el mensaje que se envia al hub
                        await App.ChatService1.SendMessageAsync(message);



                        if (Preferences.Get("UserType", 0) == 1) //Employee
                        {
                            Task.Run(() => Services.PushNotifications.PushServices.SendPushAsync(ChatDetail.ContactID, Preferences.Get("Name", string.Empty), "📄 Archivo", "chat"));
                        }
                        else
                        {
                            Task.Run(() => Services.PushNotifications.PushServices.SendPushAsync(ChatDetail.ContactID, Preferences.Get("Company", string.Empty), "📄 Archivo", "chat"));
                        }

                        //Ocultar el teclado en ios
                        MessagingCenter.Send <ChatMessageViewModel, string>(this, "FocusKeyboardStatus", "nada");

                        //Esto es para agregarlo a la base de datos
                        await Services.Chat.ChatService.AddMessageAsync(msg);
                    }
                }
            }
            catch (Exception ex)
            {
            }

            // FileData fileData = await Plugin.FilePicker.CrossFilePicker.Current.PickFile(allowedDocumentTypes);//

            // App.Current.MainPage.DisplayAlert("JobMe", "Solo disponible para Premium", "OK");
        }
Пример #7
0
        static async Task Main(string[] args)
        {
            Console.WriteLine("User Name:");
            userName = Console.ReadLine();

            service = new ChatService();
            service.OnReceivedMessage += Service_OnReceivedMessage;

            await service.InitAsync(userName);

            Console.WriteLine("You are now connected");

            await JoinRoom();

            var keepGoing = true;

            do
            {
                var text = Console.ReadLine();
                if (text == "exit")
                {
                    await service.DisconnectAsync();

                    keepGoing = false;
                }
                else if (text == "leave")
                {
                    var message = new UserConnectedMessage(userName, room);
                    await service.LeaveChannelAsync(message);
                    await JoinRoom();
                }
                else if (text == "private")
                {
                    Console.WriteLine("Enter UserName: "******"Enter private message: ");
                    text = Console.ReadLine();

                    var message = new SimpleTextMessage(userName)
                    {
                        Text      = text,
                        Recipient = user
                    };
                    await service.SendMessageAsync(message);
                }
                else if (text == "image")
                {
                    var imagePath   = @"D:\temp\Pictures\tests\emma.jpg";
                    var imageStream =
                        new FileStream(imagePath, FileMode.Open, FileAccess.Read);
                    var bytes       = ImageHelper.ReadFully(imageStream);
                    var base64Photo = Convert.ToBase64String(bytes);
                    var message     = new PhotoMessage(userName)
                    {
                        Base64Photo = base64Photo,
                        FileEnding  = imagePath.Split('.').Last(),
                        GroupName   = room
                    };
                    await service.SendMessageAsync(message);
                }
                else
                {
                    var message = new SimpleTextMessage(userName)
                    {
                        Text      = text,
                        GroupName = room
                    };

                    await service.SendMessageAsync(message);
                }
            } while (keepGoing);
        }
Пример #8
0
 public virtual Task <Message> SendPhotoAsync(PhotoMessage message,
                                              CancellationToken cancellationToken = default)
 {
     return(Client.SendPhotoAsync(message.ChatId, message.InputOnlineFile, message.Caption, message.ParseMode,
                                  message.DisableNotification, message.ReplyToMessageId, message.ReplyMarkup, cancellationToken));
 }
Пример #9
0
        protected override void Seed(StringContex db)
        {
            User us1 = new User
            {
                LastName         = "Vadim",
                FirstName        = "Bezhkov",
                Email            = "*****@*****.**",
                Login            = "******",
                Password         = "******",
                SecondName       = "Alexandrovich",
                TimeRegistration = DateTime.Now
            };
            User us2 = new User
            {
                LastName         = "Pavel",
                FirstName        = "Kononovich",
                Email            = "*****@*****.**",
                Login            = "******",
                Password         = "******",
                SecondName       = "Alexandrovich",
                TimeRegistration = DateTime.Now
            };
            User us3 = new User
            {
                LastName         = "Sergei",
                FirstName        = "Necrashevich",
                Email            = "*****@*****.**",
                Login            = "******",
                Password         = "******",
                SecondName       = "Vladimirovich",
                TimeRegistration = DateTime.Now
            };
            User us4 = new User
            {
                LastName         = "Pavel",
                FirstName        = "Birulchik",
                Email            = "*****@*****.**",
                Login            = "******",
                Password         = "******",
                SecondName       = "Vladimirovich",
                TimeRegistration = DateTime.Now
            };
            User us5 = new User
            {
                LastName         = "Dmitriy",
                FirstName        = "Omelyanovich",
                Email            = "*****@*****.**",
                Login            = "******",
                Password         = "******",
                SecondName       = "Vinogradovich",
                TimeRegistration = DateTime.Now
            };

            db.Users.Add(us1);
            db.Users.Add(us2);
            db.Users.Add(us3);
            db.Users.Add(us4);
            db.Users.Add(us5);
            db.SaveChanges();

            Album al = new Album {
                Name = "leto", UserId = us1.Id, TimeCreation = DateTime.Now
            };
            Album a2 = new Album {
                Name = "zima", UserId = us2.Id, TimeCreation = DateTime.Now
            };
            Album a3 = new Album {
                Name = "value", UserId = us3.Id, TimeCreation = DateTime.Now
            };
            Album a4 = new Album {
                Name = "pae", UserId = us4.Id, TimeCreation = DateTime.Now
            };
            Album a5 = new Album {
                Name = "let", UserId = us5.Id, TimeCreation = DateTime.Now
            };

            db.Albums.AddRange(new List <Album>()
            {
                al, a2, a3, a4, a5
            });
            db.SaveChanges();

            Avatar av = new Avatar()
            {
                UserId = us1.Id, Path = "https://myserver.vb.com", Active = true
            };
            Avatar av1 = new Avatar()
            {
                UserId = us1.Id, Path = "https://myserver.vb.com", Active = false
            };
            Avatar av2 = new Avatar()
            {
                UserId = us1.Id, Path = "https://myserver.vb.com", Active = false
            };
            Avatar av3 = new Avatar()
            {
                UserId = us1.Id, Path = "https://myserver.vb.com", Active = false
            };
            Avatar av4 = new Avatar()
            {
                UserId = us1.Id, Path = "https://myserver.vb.com", Active = false
            };

            Avatar av5 = new Avatar()
            {
                UserId = us2.Id, Path = "https://myserver.vb.com", Active = true
            };
            Avatar av6 = new Avatar()
            {
                UserId = us2.Id, Path = "https://myserver.vb.com", Active = false
            };
            Avatar av7 = new Avatar()
            {
                UserId = us2.Id, Path = "https://myserver.vb.com", Active = false
            };
            Avatar av8 = new Avatar()
            {
                UserId = us2.Id, Path = "https://myserver.vb.com", Active = false
            };
            Avatar av9 = new Avatar()
            {
                UserId = us2.Id, Path = "https://myserver.vb.com", Active = false
            };

            Avatar av35 = new Avatar()
            {
                UserId = us3.Id, Path = "https://myserver.vb.com", Active = true
            };
            Avatar av36 = new Avatar()
            {
                UserId = us3.Id, Path = "https://myserver.vb.com", Active = false
            };
            Avatar av37 = new Avatar()
            {
                UserId = us3.Id, Path = "https://myserver.vb.com", Active = false
            };
            Avatar av38 = new Avatar()
            {
                UserId = us3.Id, Path = "https://myserver.vb.com", Active = false
            };
            Avatar av39 = new Avatar()
            {
                UserId = us3.Id, Path = "https://myserver.vb.com", Active = false
            };

            Avatar av45 = new Avatar()
            {
                UserId = us4.Id, Path = "https://myserver.vb.com", Active = true
            };
            Avatar av46 = new Avatar()
            {
                UserId = us4.Id, Path = "https://myserver.vb.com", Active = false
            };
            Avatar av47 = new Avatar()
            {
                UserId = us4.Id, Path = "https://myserver.vb.com", Active = false
            };
            Avatar av48 = new Avatar()
            {
                UserId = us4.Id, Path = "https://myserver.vb.com", Active = false
            };
            Avatar av49 = new Avatar()
            {
                UserId = us4.Id, Path = "https://myserver.vb.com", Active = false
            };

            db.Avatars.AddRange(new List <Avatar>()
            {
                av, av1, av2, av3, av4, av5, av6, av7, av8, av9, av35,
                av36, av3, av38, av39, av45, av46, av47, av48, av49,
            });
            db.SaveChanges();

            Dialog dial = new Dialog()
            {
                Name = "Tratata", TimeCreation = DateTime.Now
            };
            Dialog dial2 = new Dialog()
            {
                Name = "Tratata", TimeCreation = DateTime.Now
            };
            Dialog dial3 = new Dialog()
            {
                Name = "Tratata", TimeCreation = DateTime.Now
            };
            Dialog dial4 = new Dialog()
            {
                Name = "Tratata", TimeCreation = DateTime.Now
            };
            Dialog dial5 = new Dialog()
            {
                Name = "Tratata", TimeCreation = DateTime.Now
            };

            db.Dialogs.AddRange(new List <Dialog>()
            {
                dial, dial2, dial3, dial4, dial5
            });
            db.SaveChanges();

            Friend friend = new Friend()
            {
                User1Id = us1.Id, User2Id = us2.Id
            };
            Friend friend1 = new Friend()
            {
                User1Id = us2.Id, User2Id = us3.Id
            };
            Friend friend2 = new Friend()
            {
                User1Id = us2.Id, User2Id = us4.Id
            };
            Friend friend3 = new Friend()
            {
                User1Id = us2.Id, User2Id = us5.Id
            };
            Friend friend4 = new Friend()
            {
                User1Id = us1.Id, User2Id = us3.Id
            };
            Friend friend5 = new Friend()
            {
                User1Id = us1.Id, User2Id = us4.Id
            };
            Friend friend6 = new Friend()
            {
                User1Id = us1.Id, User2Id = us5.Id
            };

            db.Friends.AddRange(new List <Friend>()
            {
                friend, friend1, friend2, friend3,
                friend4, friend5, friend6
            });
            db.SaveChanges();


            LikeAvatar like1 = new LikeAvatar()
            {
                UserId = us1.Id, Сondition = true, Avatars = av1
            };
            LikeAvatar like2 = new LikeAvatar()
            {
                UserId = us2.Id, Сondition = true, Avatars = av2
            };
            LikeAvatar like3 = new LikeAvatar()
            {
                UserId = us3.Id, Сondition = true, Avatars = av1
            };
            LikeAvatar like4 = new LikeAvatar()
            {
                UserId = us4.Id, Сondition = true, Avatars = av2
            };

            db.LikeAvatars.Add(like1);
            db.LikeAvatars.Add(like2);
            db.LikeAvatars.Add(like3);
            db.LikeAvatars.Add(like4);
            db.SaveChanges();

            Message mes7 = new Message()
            {
                DialogId = dial.Id, Text = "Hello", TextChanged = false, Users = us1
            };
            Message mes1 = new Message()
            {
                DialogId = dial2.Id, Text = "Hello friend", TextChanged = false, Users = us2
            };
            Message mes2 = new Message()
            {
                DialogId = dial3.Id, Text = "yes", TextChanged = false, Users = us3
            };
            Message mes3 = new Message()
            {
                DialogId = dial4.Id, Text = "no", TextChanged = false, Users = us4
            };
            Message mes4 = new Message()
            {
                DialogId = dial5.Id, Text = "Good", TextChanged = false, Users = us1
            };
            Message mes5 = new Message()
            {
                DialogId = dial.Id, Text = "Fine", TextChanged = false, Users = us2
            };
            Message mes6 = new Message()
            {
                DialogId = dial3.Id, Text = "Red", TextChanged = false, Users = us1
            };

            db.Messages.AddRange(new List <Message>()
            {
                mes7, mes1, mes2, mes3, mes4, mes5, mes6
            });
            db.SaveChanges();

            MessageAvatar ma = new MessageAvatar()
            {
                AvatarId = av1.Id, MessageId = mes1.Id
            };
            MessageAvatar ma1 = new MessageAvatar()
            {
                AvatarId = av2.Id, MessageId = mes2.Id
            };
            MessageAvatar ma2 = new MessageAvatar()
            {
                AvatarId = av3.Id, MessageId = mes3.Id
            };
            MessageAvatar ma3 = new MessageAvatar()
            {
                AvatarId = av4.Id, MessageId = mes4.Id
            };
            MessageAvatar ma4 = new MessageAvatar()
            {
                AvatarId = av5.Id, MessageId = mes5.Id
            };

            db.MessageAvatars.AddRange(new List <MessageAvatar> {
                ma, ma1, ma2, ma3, ma4
            });
            db.SaveChanges();

            Photo p1 = new Photo()
            {
                Path = "https://myserver.vb.com", AlbumId = al.Id, TimeCreation = DateTime.Now
            };
            Photo p2 = new Photo()
            {
                Path = "https://myserver.vb.com", AlbumId = a2.Id, TimeCreation = DateTime.Now
            };
            Photo p3 = new Photo()
            {
                Path = "https://myserver.vb.com", AlbumId = a3.Id, TimeCreation = DateTime.Now
            };
            Photo p4 = new Photo()
            {
                Path = "https://myserver.vb.com", AlbumId = a4.Id, TimeCreation = DateTime.Now
            };
            Photo p5 = new Photo()
            {
                Path = "https://myserver.vb.com", AlbumId = a5.Id, TimeCreation = DateTime.Now
            };

            db.Photos.AddRange(new List <Photo>()
            {
                p1, p2, p3, p4, p5
            });
            db.SaveChanges();


            PhotoMessage pm = new PhotoMessage()
            {
                PhotoId = p1.Id, MessageId = mes1.Id
            };
            PhotoMessage pm1 = new PhotoMessage()
            {
                PhotoId = p1.Id, MessageId = mes7.Id
            };
            PhotoMessage pm2 = new PhotoMessage()
            {
                PhotoId = p2.Id, MessageId = mes3.Id
            };
            PhotoMessage pm3 = new PhotoMessage()
            {
                PhotoId = p3.Id, MessageId = mes4.Id
            };
            PhotoMessage pm4 = new PhotoMessage()
            {
                PhotoId = p4.Id, MessageId = mes2.Id
            };
            PhotoMessage pm5 = new PhotoMessage()
            {
                PhotoId = p1.Id, MessageId = mes3.Id
            };

            db.PhotoMessages.AddRange(new List <PhotoMessage> {
                pm, pm1, pm2, pm3, pm4, pm5
            });
            db.SaveChanges();

            LikePhoto like5 = new LikePhoto()
            {
                UserId = us1.Id, Сondition = true, Photos = p1
            };
            LikePhoto like6 = new LikePhoto()
            {
                UserId = us2.Id, Сondition = true, Photos = p2
            };
            LikePhoto like7 = new LikePhoto()
            {
                UserId = us3.Id, Сondition = true, Photos = p3
            };
            LikePhoto like8 = new LikePhoto()
            {
                UserId = us4.Id, Сondition = true, Photos = p4
            };

            db.LikePhotos.Add(like5);
            db.LikePhotos.Add(like6);
            db.LikePhotos.Add(like7);
            db.LikePhotos.Add(like8);
            db.SaveChanges();

            UserDialog ud1 = new UserDialog()
            {
                UserId = us1.Id, DialogId = dial.Id, TimeCreation = DateTime.Now
            };
            UserDialog ud2 = new UserDialog()
            {
                UserId = us2.Id, DialogId = dial2.Id, TimeCreation = DateTime.Now
            };
            UserDialog ud3 = new UserDialog()
            {
                UserId = us3.Id, DialogId = dial3.Id, TimeCreation = DateTime.Now
            };
            UserDialog ud4 = new UserDialog()
            {
                UserId = us4.Id, DialogId = dial4.Id, TimeCreation = DateTime.Now
            };
            UserDialog ud5 = new UserDialog()
            {
                UserId = us5.Id, DialogId = dial5.Id, TimeCreation = DateTime.Now
            };

            db.UserDialogs.AddRange(new List <UserDialog>()
            {
                ud1, ud2, ud3, ud4, ud5
            });
            db.SaveChanges();
            base.Seed(db);
        }