Ejemplo n.º 1
0
        static void InsertAppointments(ContextService DataBase, long IdProgramacionRuta, int Duracion, System.Collections.IEnumerable appointments, System.Collections.IEnumerable resources)
        {
            var newAppointments = DevExpress.Web.Mvc.SchedulerExtension.GetAppointmentsToInsert <ProgramacionRutaDetalle>("RutaScheduler", appointments, resources,
                                                                                                                          AppointmentStorage, ResourceStorage);

            bool save = false;

            foreach (var appointment in newAppointments)
            {
                if (appointment != null)
                {
                    var model = new ProgramacionRutaDetalle();

                    model.IdProgramacionRuta = (int)IdProgramacionRuta;
                    model.AsignarId();

                    model.IdCliente          = appointment.IdCliente;
                    model.IdClienteDireccion = appointment.IdClienteDireccion;

                    model.FechaInicio = appointment.FechaInicio;
                    model.FechaFin    = model.FechaInicio.Value.AddMinutes(Duracion).AddSeconds(-1);

                    DataBase.ProgramacionRutaDetalles.Insert(model);

                    save = true;
                }
            }

            if (save)
            {
                DataBase.Save();
            }
        }
Ejemplo n.º 2
0
        public ActionResult CreateAppointment(long IdProgramacionRuta, int Duracion, string start, string idClienteDireccion)
        {
            try
            {
                DateTime fechaInicio = DateTime.Parse(start, CultureInfo.InvariantCulture);
                DateTime fechaFin    = fechaInicio.AddMinutes(Duracion).AddSeconds(-1);

                string[] keyParts = idClienteDireccion.Split('-');

                var model = new ProgramacionRutaDetalle()
                {
                    IdProgramacionRuta = (int)IdProgramacionRuta,
                    IdCliente          = Convert.ToInt32(keyParts[0]),
                    IdClienteDireccion = Convert.ToInt32(keyParts[1]),
                    FechaInicio        = fechaInicio,
                    FechaFin           = fechaFin
                };

                model.AsignarId();

                DataBase.ProgramacionRutaDetalles.Insert(model);
                DataBase.Save();

                ViewData["id"] = model.IdProgramacionRutaDetalle;
            }
            catch (Exception e)
            {
                ViewData["SchedulerErrorText"] = e.Message;
            }


            ViewBag.IdProgramacionRuta = IdProgramacionRuta;
            ViewBag.Duracion           = Duracion;

            return(RutaSchedulerPartial(IdProgramacionRuta, Duracion));
        }