コード例 #1
0
        public ActionResult GridViewPartialAddNew([ModelBinder(typeof(DevExpressEditorsBinder))] rendevusistemi.Database.Data.Emploies item)
        {
            var model = db.Employes;

            if (ModelState.IsValid)
            {
                try
                {
                    model.Add(item);
                    db.SaveChanges();
                }
                catch (Exception e)
                {
                    ViewData["EditError"] = e.Message;
                }
            }
            else
            {
                ViewData["EditError"] = "Please, correct all errors.";
            }
            return(PartialView("_GridViewPartial", model.ToList()));
        }
コード例 #2
0
        static void UpdateAppointments(rendevusistemi.Database.MyDbContext appointmentContext, rendevusistemi.Database.MyDbContext resourceContext)
        {
            var appointments = appointmentContext.Appointmenties.ToList();
            var resources    = resourceContext.Employes;

            var updAppointments = DevExpress.Web.Mvc.SchedulerExtension.GetAppointmentsToUpdate <rendevusistemi.Database.Data.Appointments>("Scheduler1", appointments, resources,
                                                                                                                                            AppointmentStorage, ResourceStorage);

            foreach (var appointment in updAppointments)
            {
                var origAppointment = appointments.FirstOrDefault(a => a.Id == appointment.Id);
                appointmentContext.Entry(origAppointment).CurrentValues.SetValues(appointment);
            }
            appointmentContext.SaveChanges();
        }
コード例 #3
0
        static void DeleteAppointments(rendevusistemi.Database.MyDbContext appointmentContext, rendevusistemi.Database.MyDbContext resourceContext)
        {
            var appointments = appointmentContext.Appointmenties.ToList();
            var resources    = resourceContext.Employes;

            var delAppointments = DevExpress.Web.Mvc.SchedulerExtension.GetAppointmentsToRemove <rendevusistemi.Database.Data.Appointments>("Scheduler1", appointments, resources,
                                                                                                                                            AppointmentStorage, ResourceStorage);

            foreach (var appointment in delAppointments)
            {
                var delAppointment = appointments.FirstOrDefault(a => a.Id == appointment.Id);
                if (delAppointment != null)
                {
                    appointmentContext.Appointmenties.Remove(delAppointment);
                }
            }
            appointmentContext.SaveChanges();
        }
コード例 #4
0
        static void InsertAppointments(rendevusistemi.Database.MyDbContext appointmentContext, rendevusistemi.Database.MyDbContext resourceContext)
        {
            var appointments = appointmentContext.Appointmenties.ToList();

            var resources = resourceContext.Employes.ToList();

            var newAppointments = DevExpress.Web.Mvc.SchedulerExtension.GetAppointmentsToInsert <rendevusistemi.Database.Data.Appointments>("Scheduler1", appointments, resources,
                                                                                                                                            AppointmentStorage, ResourceStorage);

            MyDbContext db = new MyDbContext();


            foreach (var appointment in newAppointments)
            {
                var    isim = db.Employes.Where(a => a.Id == appointment.EmployeId).FirstOrDefault();
                string aa   = string.Concat(isim.Fullname, " ", appointment.Description);
                appointment.Description = aa;
                appointmentContext.Appointmenties.Add(appointment);
            }
            appointmentContext.SaveChanges();
        }