Example #1
0
        public async Task <IActionResult> Create([Bind("Id,Title,Artist,Price,Genre")] Track track)
        {
            if (ModelState.IsValid)
            {
                _context.Add(track);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(track));
        }
        /// <summary>
        /// Возвращает соловарь сегментов треков по датаи
        /// </summary>
        /// <param name="segments">Отфильтрованные сегменты трека</param>
        /// <returns>Словарь сегментов треков по датам</returns>
        /// <exception cref="Exception">A delegate callback throws an exception.</exception>
        public static TrackContext ToSegmentsDictionary(this IEnumerable <List <IRoutePoint> > segments)
        {
            if (segments == null)
            {
                throw new ArgumentNullException(nameof(segments));
            }
            var result     = new TrackContext();
            var enumerable = segments as List <IRoutePoint>[] ?? segments.ToArray();
            var dates      = enumerable.ToDateList();

            //Для каждой даты в полученных данных
            foreach (var dateTime in dates)
            {
                //новый трек
                var time1       = dateTime;
                var segmetpoint = (from segment in enumerable
                                   let time = time1
                                              select segment.Where(trackPoint => CheckPointInDate(time, trackPoint)).ToList()).ToList();
                //для каждого сегмента треков
                result.Add(dateTime, segmetpoint);
            }
            return(result);
        }