public GridLineModel(Line data)
        {
            var bus = data.BusesToLines.Select(x => x.Bus).FirstOrDefault();

            Id             = data.Id;
            LineName       = data.LineName;
            LineNumber     = data.LineNumber;
            Direction      = (LineDirection)data.Direction;
            IsActive       = data.IsActive;
            totalStudents  = data.totalStudents ?? 0;
            Duration       = data.Duration;
            Sun            = data.Sun.HasValue ? data.Sun.Value : false;
            SunTime        = DateHelper.TimeToString(data.SunTime);
            Mon            = data.Mon.HasValue ? data.Mon.Value : false;
            MonTime        = DateHelper.TimeToString(data.MonTime);
            Tue            = data.Tue.HasValue ? data.Tue.Value : false;
            TueTime        = DateHelper.TimeToString(data.TueTime);
            Wed            = data.Wed.HasValue ? data.Wed.Value : false;
            WedTime        = DateHelper.TimeToString(data.WedTime);
            Thu            = data.Thu.HasValue ? data.Thu.Value : false;
            ThuTime        = DateHelper.TimeToString(data.ThuTime);
            Fri            = data.Fri.HasValue ? data.Fri.Value : false;
            FriTime        = DateHelper.TimeToString(data.FriTime);
            Sut            = data.Sut.HasValue ? data.Sut.Value : false;
            SutTime        = DateHelper.TimeToString(data.SutTime);
            Bus            = bus != null ? bus.Id : (int)0;
            BusDescription = bus != null?DescriptionHelper.GetBusDescription(bus) : string.Empty;

            BusId          = bus != null ? bus.BusId : string.Empty;
            PlateNumber    = bus != null ? bus.PlateNumber : string.Empty;
            BusCompanyName = bus != null ? (bus.BusCompany != null? bus.BusCompany.companyName: string.Empty) : string.Empty;
            seats          = bus != null ? bus.seats : null;
            price          = bus != null ? bus.price : null;
        }
        public GridLineBusModel(Line data)
        {
            var bus = data.BusesToLines.Select(x => x.Bus).FirstOrDefault();

            Id             = data.Id;
            LineName       = data.LineName;
            LineNumber     = data.LineNumber;
            Direction      = (LineDirection)data.Direction;
            IsActive       = data.IsActive;
            totalStudents  = data.totalStudents ?? 0;
            Duration       = data.Duration;
            Bus            = bus != null ? bus.Id : (int)0;
            BusDescription = bus != null?DescriptionHelper.GetBusDescription(bus) : string.Empty;

            BusId          = bus != null ? bus.BusId : string.Empty;
            PlateNumber    = bus != null ? bus.PlateNumber : string.Empty;
            BusCompanyName = bus != null ? (bus.BusCompany != null ? bus.BusCompany.companyName : string.Empty) : string.Empty;
            seats          = bus != null ? bus.seats : (int?)null;
            price          = bus != null ? bus.price : (double?)null;
        }
        public JsonResult GetAvailableBuses(int lineId)
        {
            var buses = new List <SelectItemModel>();

            buses.Add(new SelectItemModel {
                Value = "0", Text = string.Empty, Title = string.Empty
            });
            using (var logic = new LineLogic()) {
                buses.AddRange(logic.GetAvailableBuses(lineId)
                               .ToList()
                               .Select(z => new SelectItemModel {
                    Value = z.Id.ToString(),
                    Text  = DescriptionHelper.GetBusDescription(z),
                    Title = DescriptionHelper.GetBusDescription(z)
                }));
            }

            return(new JsonResult {
                Data = buses
            });
        }