/// <summary>
        /// Data items rage request
        /// </summary>
        /// <param name="startIndex">Start range index</param>
        /// <param name="pageCount">Items count</param>
        public void FetchRangeCommand(int startIndex, int pageCount)
        {
            Task.Run(() =>
            {
                RequestedData <HttpResponce> result;
                using (var db = new HttpResponcesContext())
                {
                    int realPageCount;
                    var httpResponcesCount = db.HttpResponces.Count();
                    if (httpResponcesCount < startIndex + pageCount)
                    {
                        realPageCount = pageCount;
                    }
                    else
                    {
                        realPageCount = httpResponcesCount - startIndex;
                    }

                    var selectedResponces = db.HttpResponces.OrderBy(k => k.Id).Skip(startIndex).Take(pageCount);
                    var requestedList     = new List <HttpResponce>(selectedResponces);

                    result = new RequestedData <HttpResponce>(startIndex,
                                                              realPageCount,
                                                              requestedList,
                                                              httpResponcesCount);
                }

                if (ListUpdates != null)
                {
                    ListUpdates(new List <ServerListChanging <HttpResponce> > {
                        result
                    });
                }
            });
        }
        private void GenerateHttpResponces(int count)
        {
            var rand = new Random();

            using (var db = new HttpResponcesContext())
            {
                for (int i = 0; i < count; i++)
                {
                    HttpResponce newResponce = null;
                    switch (rand.Next(3))
                    {
                    case 0:
                    {
                        newResponce = new HttpTextResponce(DateTime.Now,
                                                           (MimeTypes)rand.Next(2),
                                                           rand.Next(100),
                                                           "UTF8");
                        break;
                    }

                    case 1:
                    {
                        newResponce = new HttpImageResponce(DateTime.Now,
                                                            (MimeTypes)rand.Next(2, 4),
                                                            rand.Next(100, 1000),
                                                            new Size(480, 360),
                                                            256);
                        break;
                    }

                    case 2:
                    {
                        newResponce = new HttpVideoResponce(DateTime.Now,
                                                            MimeTypes.Video,
                                                            rand.Next(1000, 10000),
                                                            new Size(640, 780),
                                                            new TimeSpan(0, rand.Next(1, 60), rand.Next(0, 60)),
                                                            "KMP");
                        break;
                    }
                    }
                    if (newResponce != null)
                    {
                        db.HttpResponces.Add(newResponce);
                    }
                }
                db.SaveChanges();
            }
        }
        private void GenerateHttpResponces(int count)
        {
            try
            {
                var rand = new Random();
                using (var db = new HttpResponcesContext())
                {
                    if (db.HttpResponces.Any())
                    {
#if !RESET_DATA
                        return;
#endif
                    }

                    //Clear old data
                    db.HttpResponces.Clear();
                    db.SaveChanges();

                    for (int i = 0; i < count; i++)
                    {
                        HttpResponce newResponce = null;
                        switch (rand.Next(3))
                        {
                        case 0:
                        {
                            newResponce = new HttpTextResponce(DateTime.Now,
                                                               (MimeTypes)rand.Next(2),
                                                               rand.Next(100),
                                                               "UTF8");
                            break;
                        }

                        case 1:
                        {
                            newResponce = new HttpImageResponce(DateTime.Now,
                                                                (MimeTypes)rand.Next(2, 4),
                                                                rand.Next(100, 1000),
                                                                new Size(480, 360),
                                                                256);
                            break;
                        }

                        case 2:
                        {
                            newResponce = new HttpVideoResponce(DateTime.Now,
                                                                MimeTypes.Video,
                                                                rand.Next(1000, 10000),
                                                                new Size(640, 780),
                                                                new TimeSpan(0, rand.Next(1, 60), rand.Next(0, 60)),
                                                                "KMP");
                            break;
                        }
                        }
                        if (newResponce != null)
                        {
                            db.HttpResponces.Add(newResponce);
                        }
                    }
                    db.SaveChanges();
                }
            }
            catch (Exception exception)
            {
                Trace.WriteLine(exception);
            }
        }