public MapStateModel GetState()
        {
            var res = new MapStateModel();

            using (var logic = new LineLogic())
            {
                res.Lines = logic.GetList().Select(z => new LineModel(z)).ToList();
                foreach (var line in res.Lines)
                {
                    line.Stations = logic.GetStations(line.Id)
                                    .OrderBy(z => z.Position)
                                    .Select(z => new StationToLineModel(z))
                                    .ToList();
                }
            }
            using (var logic = new StationsLogic())
            {
                res.Stations = logic.GetList().Select(z => new StationModel(z)).ToList();
                foreach (var station in res.Stations)
                {
                    station.Students = logic.GetStudents(station.Id)
                                       .Select(z => new StudentToLineModel(z))
                                       .ToList();
                }
            }
            using (var logic = new tblStudentLogic())
            {
                res.Students = logic.GetActiveStudents()
                               .Select(z => new StudentShortInfo(z))
                               .ToList();
            }
            return(res);
        }
Beispiel #2
0
 //[Authorize]
 //public JsonResult regPay1(string h)
 //{
 //    return Json(JsonRequestBehavior.AllowGet);
 //}
 //------------------------------------//
 // GET: tblStudent
 public ActionResult Index()
 {
     using (var logic = new tblStudentLogic())
     {
         ViewBag.Classes       = logic.Classes();
         ViewBag.Shicvas       = logic.Shicvas();
         ViewBag.DefaultCityId = logic.DefaultCityId;
     }
     if (ViewBag.DefaultCityId > 0)
     {
         using (var logic5 = new tblStreetsLogic())
         {
             ViewBag.DefaultCity = logic5.GetCityById(ViewBag.DefaultCityId);
         }
     }
     using (var logic2 = new LineLogic())
     {
         ViewBag.Lines = logic2.GetList();
     }
     using (var logic3 = new StationsLogic())
     {
         ViewBag.Stations = logic3.GetList();
     }
     using (var logic4 = new tblFamilyLogic())
     {
         ViewBag.Families = JsonConvert.SerializeObject(logic4.GetAll().Select(z => new
         {
             Id   = z.familyId,
             Name = z.parent1FirstName + " " + z.parent1LastName +
                    (z.oneParentOnly ? "" : " / " + z.parent2FirstName + " " + z.parent2LastName)
         }));
     }
     using (var logic5 = new tblSchoolLogic())
     {
         ViewBag.Schools = JsonConvert.SerializeObject(logic5.GetList().Select(z => new
         {
             Id   = z.id,
             Name = z.name
         }));
     }
     return(View());
 }
        public HttpResponseMessage GetLines(bool _search, string nd, int rows, int page, string sidx, string sord, string filters = "")
        {
            var lines        = new List <GridLineModel>();
            var totalRecords = 0;

            using (var logic = new LineLogic())
            {
                lines = logic.GetList()
                        .Select(z => new GridLineModel(z)).ToList();
                totalRecords = logic.Lines.Count();
            }
            return(Request.CreateResponse(
                       HttpStatusCode.OK,
                       new
            {
                //total = (totalRecords + rows - 1) / rows,
                //page,
                //records = totalRecords,
                rows = lines
            }));
        }
        public JsonResult GetScheduleLines()
        {
            var lines = new List <SelectItemModel>();

            lines.Add(new SelectItemModel {
                Value = "0", Text = string.Empty, Title = string.Empty
            });
            using (var logic = new LineLogic())
            {
                lines.AddRange(logic.GetList()
                               .Select(z => new SelectItemModel
                {
                    Value = z.Id.ToString(),
                    Text  = string.Format("{0} - {1}", z.LineName, z.LineNumber),
                    Title = string.Format("{0} ({1} - {2})", z.LineName, z.LineNumber, DictExpressionBuilderSystem.Translate("General." + (LineDirection)z.Direction))
                }).ToList());
            }

            return(new JsonResult {
                Data = lines
            });
        }
        public bool PopulateLinesPlan()
        {
            var linesIds = new List <int>();
            var dateFrom = DateHelper.GetSunday(DateTime.Now); // DateTime.Now.AddDays(1).Date;
            var dateTo   = dateFrom.AddDays(7).Date;

            using (var logic = new LineLogic())
            {
                linesIds = logic.GetList().Select(x => x.Id).ToList();
            }
            var parameters = new ScheduleParamsModel
            {
                LinesIds   = string.Join(",", linesIds),
                DateFrom   = DateHelper.DateToString(dateFrom),
                DateTo     = DateHelper.DateToString(dateTo),
                ArriveTime = true,
                LeaveTime  = true,
                Sun        = true,
                Mon        = true,
                Tue        = true,
                Wed        = true,
                Thu        = true,
                Fri        = true,
                Sut        = true,
            };

            using (var logic = new tblLinesPlanLogic()) {
                // 0 Step - Remove all plans that has no line attached to it
                logic.DeleteAllUnbindedPlans();
                // 1 Step - Setting tblLines to LinesPlan state
                logic.SyncLinesToPlans();
            }
            // 2 Step - Generate new schedule sets by tblLines state
            var schedule = GenerateSchedule(parameters).ToList();

            // 3 Step - save new sets to tblSchedule
            return(SaveGeneratedShcedule(schedule, dateFrom, dateTo));
        }