예제 #1
0
        public JsonResult LoadSessionEvents(string start, string end)
        {
            var startDate = DateTimeOffset.Parse(start);
            var endDate   = DateTimeOffset.Parse(end);

            var sessions = _formationService.GetSessionsBetweenDates(startDate, endDate);

            var events = new List <Object>();

            foreach (var session in sessions)
            {
                var formateurId = session.Formateur.Id.ToByteArray();
                //var salleId = session.Salle.Id.ToByteArray();
                //var newId = formateurId.XOR(salleId);
                //var id = new Guid(newId);

                var color = session.Formateur.Id.ToHexColor();

                var resourceIds = new List <Guid>();
                resourceIds.Add(session.Formateur.Id);
                double duree = 0.0;
                if (session.UtiliseDureeSession)
                {
                    duree = (double)session.Duree;
                }
                else
                {
                    duree = (double)session.Formation.Duree;
                }
                events.Add(new
                {
                    Id          = session.Id,
                    ResourceIds = resourceIds,
                    Title       = session.Formation.Titre,
                    Start       = session.Date.Value.ToString("yyyy-MM-ddTHH:mm:ssZ"),
                    End         = session.Date.Value.AddHours(duree).ToString("yyyy-MM-ddTHH:mm:ssZ"),
                    Color       = color,
                    Session     = session
                });
            }

            return(Json(events));
        }