public ContentResult Save(int?id, FormCollection actionValues)
        {
            var action = new DataAction(actionValues);

            try
            {
                var changedEvent = DHXEventsHelper.Bind <Calendario>(actionValues, new System.Globalization.CultureInfo("pt-BR"));
                switch (action.Type)
                {
                case DataActionTypes.Insert:
                    db.Calendario.Add(changedEvent);
                    break;

                case DataActionTypes.Delete:
                    db.Entry(changedEvent).State = EntityState.Deleted;
                    break;

                default:    // "update"
                    db.Entry(changedEvent).State = EntityState.Modified;
                    break;
                }
                db.SaveChanges();
                action.TargetId = changedEvent.Id;
            }
            catch (Exception a)
            {
                action.Type = DataActionTypes.Error;
            }

            return(new AjaxSaveResponse(action));
        }
        public ContentResult Save(int?id, FormCollection actionValues)
        {
            var action = new DataAction(actionValues);

            try
            {
                var changedEvent = (CalendarEvent)DHXEventsHelper.Bind(typeof(CalendarEvent), actionValues);

                switch (action.Type)
                {
                case DataActionTypes.Insert:
                    action.TargetId = Insert(changedEvent);
                    break;

                case DataActionTypes.Delete:

                    Delete(changedEvent);

                    break;

                default:
                    Update(changedEvent);
                    break;
                }
            }
            catch
            {
                action.Type = DataActionTypes.Error;
            }
            return((ContentResult) new AjaxSaveResponse(action));
        }
Exemple #3
0
        public ActionResult Save(int?id, FormCollection actionValues)
        {
            var    action = new DataAction(actionValues);
            string userId = User.Identity.GetUserId();
            var    user   = db.Managers.Find(userId);

            try
            {
                var changedEvent = DHXEventsHelper.Bind <SchoolEvent>(actionValues);
                switch (action.Type)
                {
                case DataActionTypes.Insert:
                    changedEvent.School = user.school;
                    db.SchoolEvents.Add(changedEvent);
                    break;

                case DataActionTypes.Delete:
                    db.Entry(changedEvent).State = EntityState.Deleted;
                    break;

                default:    // "update"
                    changedEvent.School          = user.school;
                    db.Entry(changedEvent).State = EntityState.Modified;
                    break;
                }
                db.SaveChanges();
                action.TargetId = changedEvent.Id;
            }
            catch (Exception)
            {
                action.Type = DataActionTypes.Error;
            }

            return(new AjaxSaveResponse(action));
        }
Exemple #4
0
        public ContentResult NativeSave(DataAction action, ValidEvent changedEvent, FormCollection actionValues)
        {
            try
            {
                switch (action.Type)
                {
                case DataActionTypes.Insert:
                    Repository.CreateValidEvent(changedEvent);
                    break;

                case DataActionTypes.Delete:
                    changedEvent = Repository.ValidEvents.SingleOrDefault(ev => ev.id == action.SourceId);
                    Repository.RemoveValidEvent((int)action.SourceId);
                    break;

                default:    // "update"
                    var eventToUpdate = Repository.ValidEvents.SingleOrDefault(ev => ev.id == action.SourceId);
                    Repository.UpdateValidEvent(changedEvent);
                    DHXEventsHelper.Update(eventToUpdate, changedEvent, new List <string>()
                    {
                        "id"
                    });
                    break;
                }
                //data.SubmitChanges();
                action.TargetId = changedEvent.id;
            }
            catch
            {
                action.Type = DataActionTypes.Error;
            }

            return(new AjaxSaveResponse(action));
        }
        public ContentResult NativeSave(DataAction action, ValidEvent changedEvent, FormCollection actionValues)
        {
            var data = new DHXSchedulerDataContext();

            try
            {
                switch (action.Type)
                {
                case DataActionTypes.Insert:
                    data.ValidEvents.InsertOnSubmit(changedEvent);
                    break;

                case DataActionTypes.Delete:
                    changedEvent = data.ValidEvents.SingleOrDefault(ev => ev.id == action.SourceId);
                    data.ValidEvents.DeleteOnSubmit(changedEvent);
                    break;

                default:    // "update"
                    var eventToUpdate = data.ValidEvents.SingleOrDefault(ev => ev.id == action.SourceId);
                    DHXEventsHelper.Update(eventToUpdate, changedEvent, new List <string>()
                    {
                        "id"
                    });
                    break;
                }
                data.SubmitChanges();
                action.TargetId = changedEvent.id;
            }
            catch (Exception a)
            {
                action.Type = DataActionTypes.Error;
            }

            return(new AjaxSaveResponse(action));
        }
        public ContentResult Save(int?id, FormCollection actionValues)
        {
            var    action      = new DataAction(actionValues);
            var    stylists    = db.Stylists.ToList();
            string currentUser = User.Identity.GetUserId();
            var    stylistInfo = db.Stylists.Where(c => c.UserId.Equals(currentUser)).FirstOrDefault();

            try
            {
                var changedEvent = DHXEventsHelper.Bind <Event>(actionValues);
                switch (action.Type)
                {
                case DataActionTypes.Insert:
                    changedEvent.StylistId = stylistInfo.Id;
                    db.Events.Add(changedEvent);
                    break;

                case DataActionTypes.Delete:
                    db.Entry(changedEvent).State = EntityState.Deleted;
                    break;

                default:    // "update"
                    db.Entry(changedEvent).State = EntityState.Modified;
                    break;
                }
                db.SaveChanges();
                action.TargetId = changedEvent.Id;
            }
            catch (Exception)
            {
                action.Type = DataActionTypes.Error;
            }

            return(new AjaxSaveResponse(action));
        }
        public ActionResult Save(int?id, FormCollection actionValues)
        {
            var action = new DataAction(actionValues);

            try
            {
                var changedEvent = DHXEventsHelper.Bind <Calendar>(actionValues);
                switch (action.Type)
                {
                case DataActionTypes.Insert:
                    db.Appointments.Add(changedEvent);
                    break;

                case DataActionTypes.Delete:
                    db.Entry(changedEvent).State = EntityState.Deleted;
                    break;

                default:    // "update"
                    db.Entry(changedEvent).State = EntityState.Modified;
                    break;
                }
                db.SaveChanges();
                action.TargetId = changedEvent.Id;
            }
            catch (Exception)
            {
                action.Type = DataActionTypes.Error;
            }

            return(new AjaxSaveResponse(action));
        }
Exemple #8
0
        public ContentResult Save(int?id, FormCollection actionValues)
        {
            var action = new DataAction(actionValues);

            try
            {
                var changedEvent = (CalendarEvent)DHXEventsHelper.Bind(typeof(CalendarEvent), actionValues);



                switch (action.Type)
                {
                case DataActionTypes.Insert:
                    //do insert
                    // action.TargetId = changedEvent.id;//assign postoperational id
                    break;

                case DataActionTypes.Delete:
                    //do delete
                    break;

                default:    // "update"
                    //do update
                    break;
                }
            }
            catch
            {
                action.Type = DataActionTypes.Error;
            }
            return((ContentResult) new AjaxSaveResponse(action));
        }
Exemple #9
0
        public ActionResult Save(int?id, FormCollection actionValues)
        {
            var action = new DataAction(actionValues);

            try
            {
                var changedEvent = DHXEventsHelper.Bind <gEvent>(actionValues);
                switch (action.Type)
                {
                case DataActionTypes.Insert:
                    existEvent.myEvent.Add(changedEvent);
                    break;

                case DataActionTypes.Delete:     //will add later
                    break;

                default:    // "update" add later
                    break;
                }


                action.TargetId = changedEvent.Id;
            }
            catch (Exception a)
            {
                action.Type = DataActionTypes.Error;
            }

            return(new AjaxSaveResponse(action));
        }
Exemple #10
0
        public ContentResult Save(int?id, FormCollection actionValues)
        {
            var    entityContext = new EntityContext();
            var    action        = new DataAction(actionValues);
            var    cInfo         = new CalendarInfo();
            int    Id            = 0;
            string typeOfAction  = string.Empty;

            try
            {
                var maxData = entityContext.calendarInfo.Where(q => q.Type == "TempleEvent").ToList();
                if (maxData != null && maxData.Count > 0)
                {
                    var maxId = maxData?.Max(q => q.Id);
                    Id = maxId.Value;
                }
                var changedEvent = (CalendarEvent)DHXEventsHelper.Bind(typeof(CalendarEvent), actionValues);
                switch (action.Type)
                {
                case DataActionTypes.Insert:
                {
                    //cInfo.Id = ++Id; cInfo.Text = changedEvent.text; cInfo.StartDate = changedEvent.start_date; cInfo.EndDate = changedEvent.end_date; cInfo.Type = "TempleEvent";
                    //entityContext.calendarInfo.Add(cInfo);
                    //typeOfAction = "Temple Event Created";
                }
                break;

                case DataActionTypes.Delete:
                {
                    cInfo = entityContext.calendarInfo.FirstOrDefault(q => q.Id == changedEvent.id);
                    var report = entityContext.reportInfo.FirstOrDefault(q => q.ReferenceTxnID == cInfo.ReferenceTxnID);
                    entityContext.reportInfo.Remove(report);
                    entityContext.calendarInfo.Remove(cInfo);
                    typeOfAction = "Temple Event Cancelled;" + report.FromEmailAddress;
                    entityContext.SaveChanges();
                    cInfo.Name = $"{cInfo.Name} {report.PhoneNo} {cInfo.Text}";
                    Notifications.NotificationToAdmins(typeOfAction, cInfo);
                }
                break;

                default:    // "update"
                {
                    //cInfo = entityContext.calendarInfo.FirstOrDefault(q => q.Id == changedEvent.id);
                    //cInfo.Id = changedEvent.id; cInfo.Text = changedEvent.text; cInfo.StartDate = changedEvent.start_date; cInfo.EndDate = changedEvent.end_date; cInfo.Type = "TempleEvent";
                    //entityContext.calendarInfo.AddOrUpdate(cInfo);
                    //typeOfAction = "Temple Event Modified";
                }
                break;
                }
            }
            catch (Exception ex)
            {
                action.Type = DataActionTypes.Error;
            }
            ViewBag.schedule = GetScheduler();
            //return (ContentResult)Index();
            return((ContentResult) new AjaxSaveResponse(action));
        }
Exemple #11
0
        public ActionResult Save(FormCollection actionValues)
        {
            var scheduler = new DHXScheduler(this);

            var action = new DataAction(actionValues);

            // scheduler.InitialValues.Add("text");
            try
            {
                var changedEvent = (Schedule)DHXEventsHelper.Bind(typeof(Schedule), actionValues);
                int d            = Convert.ToInt32(System.Web.HttpContext.Current.Session["ide"]);
                var dat          = new BookingBusiness();
                // changedEvent.text = dat.GetSaveBooking(d).FullName + "<br/>" + dat.GetSaveBooking(d).Physician;
                string name = dat.GetSaveBooking(d).FullName;

                switch (action.Type)
                {
                case DataActionTypes.Insert:

                    dat.InsertSaveBooking(changedEvent, d);

                    break;

                case DataActionTypes.Delete:

                    int num;
                    try
                    {
                        num = Convert.ToInt32(action.SourceId);
                    }
                    catch (Exception)
                    {
                        return(RedirectToAction("Index", "Calendar"));
                    }
                    dat.DeleteSavedBooking(num);
                    break;

                default:    // "update"
                    var evt = b.displaySchedule().SingleOrDefault(ez => ez.id == action.SourceId);

                    DHXEventsHelper.Update(evt, changedEvent, new List <string>()
                    {
                        "id"
                    });

                    //do update
                    b.UpdateSavedBooking(evt, changedEvent);
                    break;
                }

                action.TargetId = changedEvent.id;
            }
            catch
            {
                action.Type = DataActionTypes.Error;
            }
            return((ContentResult) new AjaxSaveResponse(action));
        }
        public ContentResult Save(int?id, FormCollection actionValues)
        {
            var action       = new DataAction(actionValues);
            var changedEvent = DHXEventsHelper.Bind <schedulerEvent>(actionValues);
            var entities     = new CalendarContext();
            var service      = getService();

            try
            {
                switch (action.Type)
                {
                case DataActionTypes.Insert:
                    //System.Diagnostics.Debug.WriteLine(changedEvent.text);
                    Event ge = service.Events.Insert(transformEvent(changedEvent), "primary").Execute();
                    changedEvent.user = User.Identity.GetUserName();
                    changedEvent.gid  = ge.Id;
                    entities.Events.Add(changedEvent);
                    break;

                case DataActionTypes.Delete:
                    // System.Diagnostics.Debug.WriteLine(changedEvent.gid);
                    service.Events.Delete("primary", changedEvent.gid).Execute();
                    changedEvent = entities.Events.FirstOrDefault(ev => ev.gid.Equals(changedEvent.gid));
                    entities.Events.Remove(changedEvent);
                    break;

                default:    // "update"
                    System.Diagnostics.Debug.WriteLine(changedEvent.gid);
                    var target = entities.Events.Single(e => e.gid.Equals(changedEvent.gid));
                    DHXEventsHelper.Update(target, changedEvent, new List <string> {
                        "id"
                    });
                    target = entities.Events.Single(e => e.gid.Equals(changedEvent.gid));
                    var toUpdate = service.Events.Get("primary", target.gid).Execute();
                    toUpdate.Summary = target.text;
                    toUpdate.Start   = new Google.Apis.Calendar.v3.Data.EventDateTime
                    {
                        DateTime = target.start_date.ToUniversalTime()
                    };
                    toUpdate.End = new Google.Apis.Calendar.v3.Data.EventDateTime
                    {
                        DateTime = target.end_date.ToUniversalTime()
                    };
                    service.Events.Update(toUpdate, "primary", toUpdate.Id).Execute();
                    break;
                }
                entities.SaveChanges();
                action.TargetId = changedEvent.id;
            }
            catch (Exception)
            {
                action.Type = DataActionTypes.Error;
            }

            return(new AjaxSaveResponse(action));
        }
Exemple #13
0
        public ActionResult Save(FormCollection actionValues)
        {
            var scheduler = new DHXScheduler(this);

            var action = new DataAction(actionValues);

            // scheduler.InitialValues.Add("text");
            try
            {
                var changedEvent = (Schedule)DHXEventsHelper.Bind(typeof(Schedule), actionValues);


                switch (action.Type)
                {
                case DataActionTypes.Insert:

                    b.InsertBook(changedEvent);

                    break;

                case DataActionTypes.Delete:

                    int num;
                    try
                    {
                        num = Convert.ToInt32(action.SourceId);
                    }
                    catch (Exception)
                    {
                        return(RedirectToAction("Index", "Calendar"));
                    }
                    b.DeleteSavedBooking(num);
                    break;

                default:    // "update"
                    var evt = b.displaySchedule().SingleOrDefault(ez => ez.id == action.SourceId);

                    DHXEventsHelper.Update(evt, changedEvent, new List <string>()
                    {
                        "id"
                    });

                    //do update
                    b.UpdateSavedBooking(evt, changedEvent);
                    break;
                }

                action.TargetId = changedEvent.id;
            }
            catch
            {
                action.Type = DataActionTypes.Error;
            }
            return((ContentResult) new AjaxSaveResponse(action));
        }
Exemple #14
0
        public ContentResult Save(int?id, FormCollection actionValues)
        {
            var    entityContext = new EntityContext();
            var    action        = new DataAction(actionValues);
            var    cInfo         = new CalendarInfo();
            int    Id            = 0;
            string typeOfAction  = string.Empty;

            try
            {
                var maxData = entityContext.calendarInfo.Where(q => q.Type == "Room").ToList();
                if (maxData != null && maxData.Count > 0)
                {
                    var maxId = maxData?.Max(q => q.Id);
                    Id = maxId.Value;
                }
                var changedEvent = (CalendarEvent)DHXEventsHelper.Bind(typeof(CalendarEvent), actionValues);
                switch (action.Type)
                {
                case DataActionTypes.Insert:
                {
                    cInfo.Id = ++Id; cInfo.Text = changedEvent.text; cInfo.StartDate = changedEvent.start_date; cInfo.EndDate = changedEvent.end_date; cInfo.Type = "Room";
                    entityContext.calendarInfo.Add(cInfo);
                    typeOfAction = "New Room Booked";
                }
                break;

                case DataActionTypes.Delete:
                {
                    cInfo = entityContext.calendarInfo.FirstOrDefault(q => q.Id == changedEvent.id);
                    entityContext.calendarInfo.Remove(cInfo);
                    typeOfAction = "Cancel the Room";
                }
                break;

                default:    // "update"
                {
                    cInfo    = entityContext.calendarInfo.FirstOrDefault(q => q.Id == changedEvent.id);
                    cInfo.Id = changedEvent.id; cInfo.Text = changedEvent.text; cInfo.StartDate = changedEvent.start_date; cInfo.EndDate = changedEvent.end_date; cInfo.Type = "Room";
                    entityContext.calendarInfo.AddOrUpdate(cInfo);
                    typeOfAction = "Modified the Room";
                }
                break;
                }
                entityContext.SaveChanges();
                Notifications.NotificationToAdmins(typeOfAction, cInfo);
            }
            catch (Exception ex)
            {
                action.Type = DataActionTypes.Error;
            }
            return((ContentResult) new AjaxSaveResponse(action));
        }
Exemple #15
0
        public ActionResult LightboxControl(int?id, FormCollection actionValues)
        {
            var ev = DHXEventsHelper.Bind <Event>(actionValues);

            var context = new DHXSchedulerDataContext();
            var current = context.Events.SingleOrDefault(e => e.id == ev.id);

            if (current == null)
            {
                current = ev;
            }
            return(View(current));
        }
        /// <summary>
        /// The save.
        /// </summary>
        /// <param name="id">
        /// The id.
        /// </param>
        /// <param name="actionValues">
        /// The action values.
        /// </param>
        /// <param name="officeId">
        /// The office Id.
        /// </param>
        /// <param name="userId">
        /// The user Id.
        /// </param>
        /// <returns>
        /// The <see cref="ContentResult"/>.
        /// </returns>
        public ContentResult Save(int?id, FormCollection actionValues, int officeId, int userId)
        {
            var employeeId   = this.appointmentManager.GetEmployeeIdByUserId(userId).GetValueOrDefault();
            var action       = new DataAction(actionValues);
            var changedEvent = DHXEventsHelper.Bind <DhxAppointment>(actionValues);

            changedEvent.ErrorMessages = string.Empty;
            try
            {
                switch (action.Type)
                {
                case DataActionTypes.Insert:
                case DataActionTypes.Update:
                    changedEvent = this.appointmentManager.SaveAppointment(
                        changedEvent, employeeId, officeId, false, false);
                    break;

                case DataActionTypes.Delete:
                    this.appointmentManager.DeleteAppointment(changedEvent.id, employeeId);
                    break;

                default:
                    action.Type = DataActionTypes.Error;
                    break;
                }

                action.TargetId = changedEvent.id;
            }
            catch
            {
                action.Type = DataActionTypes.Error;
            }

            if (!string.IsNullOrEmpty(changedEvent.ErrorMessages))
            {
                action.Type    = DataActionTypes.Error;
                action.Message = changedEvent.ErrorMessages;
            }
            else
            {
                action.Message = changedEvent.text;
            }

            var response = new AjaxSaveResponse(action);

            response.UpdateField("start_date", changedEvent.start_date);
            response.UpdateField("end_date", changedEvent.end_date);

            return(this.Content(response, "text/xml"));
        }
        public ContentResult CustomFormSave(DataAction action, ValidEvent changedEvent, FormCollection actionValues)
        {
            if (actionValues["actionType"] != null)
            {
                var actionType = actionValues["actionType"].ToLower();
                var data       = new DHXSchedulerDataContext();
                try
                {
                    if (actionType == "save")
                    {
                        if (data.ValidEvents.SingleOrDefault(ev => ev.id == action.SourceId) != null)
                        {
                            //update event
                            var eventToUpdate = data.ValidEvents.SingleOrDefault(ev => ev.id == action.SourceId);

                            DHXEventsHelper.Update(eventToUpdate, changedEvent, new List <string>()
                            {
                                "id"
                            });

                            action.Type = DataActionTypes.Update;
                        }
                        else
                        {
                            //create event
                            data.ValidEvents.InsertOnSubmit(changedEvent);
                            action.Type = DataActionTypes.Insert;
                        }
                    }
                    else if (actionType == "delete")
                    {
                        changedEvent = data.ValidEvents.SingleOrDefault(ev => ev.id == action.SourceId);
                        data.ValidEvents.DeleteOnSubmit(changedEvent);

                        action.Type = DataActionTypes.Delete;
                    }
                    data.SubmitChanges();
                }

                catch (Exception e)
                {
                    action.Type = DataActionTypes.Error;
                }
            }



            return(new SchedulerFormResponseScript(action, changedEvent));
        }
Exemple #18
0
        public ContentResult CustomFormSave(DataAction action, ValidEvent changedEvent, FormCollection actionValues)
        {
            if (actionValues["actionType"] != null)
            {
                var actionType = actionValues["actionType"].ToLower();

                try
                {
                    if (actionType == "save")
                    {
                        if (Repository.ValidEvents.SingleOrDefault(ev => ev.id == action.SourceId) != null)
                        {
                            //update event
                            var eventToUpdate = Repository.ValidEvents.SingleOrDefault(ev => ev.id == action.SourceId);
                            Repository.UpdateValidEvent(changedEvent);
                            DHXEventsHelper.Update(eventToUpdate, changedEvent, new List <string>()
                            {
                                "id"
                            });

                            action.Type = DataActionTypes.Update;
                        }
                        else
                        {
                            //create event
                            Repository.CreateValidEvent(changedEvent);
                            action.Type = DataActionTypes.Insert;
                        }
                    }
                    else if (actionType == "delete")
                    {
                        changedEvent = Repository.ValidEvents.SingleOrDefault(ev => ev.id == action.SourceId);
                        Repository.RemoveValidEvent((int)action.SourceId);

                        action.Type = DataActionTypes.Delete;
                    }
                    //data.SubmitChanges();
                }

                catch
                {
                    action.Type = DataActionTypes.Error;
                }
            }



            return(new SchedulerFormResponseScript(action, changedEvent));
        }
        public ActionResult Save(int?id, FormCollection actionValues)
        {
            var action = new DataAction(actionValues);

            DHXSchedulerModelsDataContext data = new DHXSchedulerModelsDataContext();

            try
            {
                var changedEvent = (Recurring)DHXEventsHelper.Bind(typeof(Recurring), actionValues);
                //operations with recurring events require some additional handling
                bool isFinished = deleteRelated(action, changedEvent, data);
                if (!isFinished)
                {
                    switch (action.Type)
                    {
                    case DataActionTypes.Insert:
                        data.Recurrings.InsertOnSubmit(changedEvent);
                        if (changedEvent.rec_type == "none")    //delete one event from the serie
                        {
                            action.Type = DataActionTypes.Delete;
                        }
                        break;

                    case DataActionTypes.Delete:
                        changedEvent = data.Recurrings.SingleOrDefault(ev => ev.id == action.SourceId);
                        data.Recurrings.DeleteOnSubmit(changedEvent);
                        break;

                    default:    // "update"
                        var eventToUpdate = data.Recurrings.SingleOrDefault(ev => ev.id == action.SourceId);
                        DHXEventsHelper.Update(eventToUpdate, changedEvent, new List <string>()
                        {
                            "id"
                        });
                        break;
                    }
                }
                data.SubmitChanges();


                action.TargetId = changedEvent.id;
            }
            catch
            {
                action.Type = DataActionTypes.Error;
            }

            return(new AjaxSaveResponse(action));
        }
Exemple #20
0
        public ActionResult Save(int?id, FormCollection actionValues)
        {
            var action       = new DataAction(actionValues);
            var changedEvent = (ValidEvent)DHXEventsHelper.Bind(typeof(ValidEvent), actionValues);

            if (action.Type != DataActionTypes.Error)
            {
                //handle changes done without lightbox - dnd, resize..
                return(NativeSave(action, changedEvent, actionValues));
            }
            else
            {
                return(CustomFormSave(action, changedEvent, actionValues));
            }
        }
Exemple #21
0
        public ActionResult CustomSave(Event changedEvent, FormCollection actionValues)
        {
            var action = new DataAction(DataActionTypes.Update, changedEvent.id, changedEvent.id);

            if (actionValues["actionButton"] != null)
            {
                try
                {
                    if (actionValues["actionButton"] == "Save")
                    {
                        if (Repository.Events.SingleOrDefault(ev => ev.id == action.SourceId) != null)
                        {
                            var eventToUpdate = Repository.Events.SingleOrDefault(ev => ev.id == action.SourceId);
                            Repository.UpdateEvents(changedEvent);
                            DHXEventsHelper.Update(eventToUpdate, changedEvent, new List <string>()
                            {
                                "id"
                            });
                        }
                        else
                        {
                            action.Type = DataActionTypes.Insert;

                            Repository.CreateEvents(changedEvent);
                        }
                    }
                    else if (actionValues["actionButton"] == "Delete")
                    {
                        action.Type  = DataActionTypes.Delete;
                        changedEvent = Repository.Events.SingleOrDefault(ev => ev.id == action.SourceId);
                        Repository.RemoveEvents((int)action.SourceId);
                    }
                    // data.SubmitChanges();
                }

                catch
                {
                    action.Type = DataActionTypes.Error;
                }
            }
            else
            {
                action.Type = DataActionTypes.Error;
            }


            return(new SchedulerFormResponseScript(action, changedEvent));
        }
Exemple #22
0
        public ActionResult Save(int?id, FormCollection actionValues)
        {
            var action       = new DataAction(actionValues);
            var changedEvent = (Event)DHXEventsHelper.Bind(typeof(Event), actionValues);

            if (action.Type != DataActionTypes.Error)
            {
                //process resize, d'n'd operations...
                return(NativeSave(changedEvent, actionValues));
            }
            else
            {
                //custom form operation
                return(CustomSave(changedEvent, actionValues));
            }
        }
Exemple #23
0
        public ContentResult Save(int?id, FormCollection actionValues)
        {
            var action = new DataAction(actionValues);

            var changedEvent = (Event)DHXEventsHelper.Bind(typeof(Event), actionValues);

            try
            {
                switch (action.Type)
                {
                case DataActionTypes.Insert:
                    if (!Repository.CreateEvents(changedEvent))
                    {
                        action.Type = DataActionTypes.Error;
                    }
                    break;

                case DataActionTypes.Delete:
                    changedEvent = Repository.Events.SingleOrDefault(ev => ev.id == action.SourceId);
                    if (!Repository.RemoveEvents((int)action.SourceId))
                    {
                        action.Type = DataActionTypes.Error;
                    }
                    break;

                default:    // "update"
                    var eventToUpdate = Repository.Events.SingleOrDefault(ev => ev.id == action.SourceId);
                    if (Repository.UpdateEvents(changedEvent))
                    {
                        action.Type = DataActionTypes.Error;
                    }
                    DHXEventsHelper.Update(eventToUpdate, changedEvent, new List <string>()
                    {
                        "id"
                    });
                    break;
                }
                //data.SubmitChanges();
                action.TargetId = changedEvent.id;
            }
            catch
            {
                action.Type = DataActionTypes.Error;
            }

            return(new AjaxSaveResponse(action));
        }
Exemple #24
0
        public ActionResult CustomSave(Event changedEvent, FormCollection actionValues)
        {
            var action = new DataAction(DataActionTypes.Update, changedEvent.id, changedEvent.id);

            if (actionValues["actionButton"] != null)
            {
                DHXSchedulerDataContext data = new DHXSchedulerDataContext();
                try
                {
                    if (actionValues["actionButton"] == "Save")
                    {
                        if (data.Events.SingleOrDefault(ev => ev.id == action.SourceId) != null)
                        {
                            var eventToUpdate = data.Events.SingleOrDefault(ev => ev.id == action.SourceId);
                            DHXEventsHelper.Update(eventToUpdate, changedEvent, new List <string>()
                            {
                                "id"
                            });
                        }
                        else
                        {
                            action.Type = DataActionTypes.Insert;
                            data.Events.InsertOnSubmit(changedEvent);
                        }
                    }
                    else if (actionValues["actionButton"] == "Delete")
                    {
                        action.Type  = DataActionTypes.Delete;
                        changedEvent = data.Events.SingleOrDefault(ev => ev.id == action.SourceId);
                        data.Events.DeleteOnSubmit(changedEvent);
                    }
                    data.SubmitChanges();
                }

                catch (Exception e)
                {
                    action.Type = DataActionTypes.Error;
                }
            }
            else
            {
                action.Type = DataActionTypes.Error;
            }


            return(new SchedulerFormResponseScript(action, changedEvent));
        }
        public ContentResult Save(int?id, FormCollection actionValues)
        {
            var action = new DataAction(actionValues);


            try
            {
                var changedEvent = (Event)DHXEventsHelper.Bind(typeof(Event), actionValues);


                switch (action.Type)
                {
                case DataActionTypes.Insert:
                    if (changedEvent.text == "New event")
                    {
                        changedEvent.text = "";
                    }
                    changedEvent.text = db.Modulo.SingleOrDefault(x => x.Id_Modulo == changedEvent.FK_Id_Modulo).Nombre + "\n" + db.Profesor.SingleOrDefault(x => x.Id_Profesor == changedEvent.FK_Id_Profesor).Nombre + "\n" + changedEvent.text;
                    ctx.Event.InsertOnSubmit(changedEvent);

                    break;

                case DataActionTypes.Delete:

                    changedEvent = ctx.Event.SingleOrDefault(ev => ev.Id == id);
                    ctx.Event.DeleteOnSubmit(changedEvent);

                    break;

                default:
                    var eventTo = ctx.Event.SingleOrDefault(ev => ev.Id == id);
                    DHXEventsHelper.Update(eventTo, changedEvent, new List <string>()
                    {
                        "Id"
                    });
                    break;
                }

                ctx.SubmitChanges();
                action.TargetId = changedEvent.Id;
            }
            catch
            {
                action.Type = DataActionTypes.Error;
            }
            return((ContentResult) new AjaxSaveResponse(action));
        }
Exemple #26
0
        public ContentResult Save(int?id, FormCollection actionValues)

        {
            var action = new DataAction(actionValues);

            try
            {
                var changedEvent = (Events)DHXEventsHelper.Bind(typeof(Events), actionValues);

                switch (action.Type)
                {
                case DataActionTypes.Insert:
                    Events EV = new Events();
                    EV.Id         = changedEvent.Id;
                    EV.Start_date = changedEvent.Start_date;
                    EV.End_date   = changedEvent.End_date;
                    EV.Text       = changedEvent.Text;
                    db.Events.Add(EV);
                    db.SaveChanges();


                    break;

                case DataActionTypes.Delete:
                    var details = db.Events.Where(x => x.Id == id).FirstOrDefault();
                    db.Events.Remove(details);
                    db.SaveChanges();

                    break;

                default:    // "update"
                    var data = db.Events.Where(x => x.Id == id).FirstOrDefault();
                    data.Start_date = changedEvent.Start_date;
                    data.End_date   = changedEvent.End_date;
                    data.Text       = changedEvent.Text;
                    db.SaveChanges();

                    break;
                }
            }
            catch
            {
                action.Type = DataActionTypes.Error;
            }
            return((ContentResult) new AjaxSaveResponse(action));
        }
        public void ProcessRequest(HttpContext context)
        {
            var action = new DataAction(context.Request.Form);
            var data   = new SchedulerDataContext();

            try
            {
                var changedEvent = (Recurring)DHXEventsHelper.Bind(typeof(Recurring), context.Request.Form);//create model object from the request fields

                bool isFinished = deleteRelated(action, changedEvent, data);
                if (!isFinished)
                {
                    switch (action.Type)
                    {
                    case DataActionTypes.Insert:     // define here your Insert logic
                        data.Recurrings.InsertOnSubmit(changedEvent);

                        break;

                    case DataActionTypes.Delete:     // define here your Delete logic
                        changedEvent = data.Recurrings.SingleOrDefault(ev => ev.id == action.SourceId);
                        data.Recurrings.DeleteOnSubmit(changedEvent);
                        break;

                    default:    // "update" // define here your Update logic
                        var updated = data.Recurrings.SingleOrDefault(ev => ev.id == action.SourceId);
                        DHXEventsHelper.Update(updated, changedEvent, new List <string>()
                        {
                            "id"
                        });


                        break;
                    }
                }
                data.SubmitChanges();
                action.TargetId = changedEvent.id;
                action          = insertRelated(action, changedEvent, data);
            }
            catch
            {
                action.Type = DataActionTypes.Error;
            }
            context.Response.ContentType = "text/xml";
            context.Response.Write(new AjaxSaveResponse(action).ToString());
        }
        public ContentResult Save(int?id, FormCollection actionValues)
        {
            var action           = new DataAction(actionValues);
            var changedEvent     = (Event)DHXEventsHelper.Bind(typeof(Event), actionValues);
            var data             = new AppUserIdentityDbContext();
            var custUserIdentity = data.Users.SingleOrDefault(u => u.UserName == HttpContext.User.Identity.Name);

            if (custUserIdentity != null && (Request.IsAuthenticated && changedEvent.user_id == custUserIdentity.Id))
            {
                try
                {
                    switch (action.Type)
                    {
                    case DataActionTypes.Insert:
                        changedEvent.room_id = Repository.Rooms.First().key;
                        Repository.CreateEvents(changedEvent);
                        break;

                    case DataActionTypes.Delete:
                        //changedEvent = Repository.Events.SingleOrDefault(ev => ev.id == action.SourceId);
                        Repository.RemoveEvents((int)action.SourceId);
                        break;

                    default:    // "update"
                        var eventToUpdate = Repository.Events.SingleOrDefault(ev => ev.id == action.SourceId);
                        Repository.UpdateEvents(eventToUpdate);
                        DHXEventsHelper.Update(eventToUpdate, changedEvent, new List <string> {
                            "id"
                        });
                        break;
                    }
                    //data.SubmitChanges();
                    action.TargetId = changedEvent.id;
                }
                catch
                {
                    action.Type = DataActionTypes.Error;
                }
            }
            else
            {
                action.Type = DataActionTypes.Error;
            }
            return(new AjaxSaveResponse(action));
        }
Exemple #29
0
        public ContentResult Save(int?id, FormCollection actionValues)
        {
            var action = new DataAction(actionValues);
            //  DHXSchedulerDataItem data = new DHXSchedulerDataItem();
            //   CalendarDataContext data = new CalendarDataContext();
            var changedEvent = (Event)DHXEventsHelper.Bind(typeof(Event), actionValues);

            var data = new CalendarDataContext();

            try
            {
                switch (action.Type)
                {
                case DataActionTypes.Insert:
                    //do insert

                    //action.TargetId = changedEvent.id;//assign postoperational id
                    changedEvent.LecturerId = "IT14121548";
                    data.Events.InsertOnSubmit(changedEvent);
                    break;

                case DataActionTypes.Delete:
                    //do delete
                    changedEvent = data.Events.SingleOrDefault(ev => ev.id == action.SourceId);
                    data.Events.DeleteOnSubmit(changedEvent);
                    break;

                default:    // "update"
                            //do update
                    var eventToUpdate = data.Events.SingleOrDefault(ev => ev.id == action.SourceId);
                    DHXEventsHelper.Update(eventToUpdate, changedEvent, new List <string>()
                    {
                        "id"
                    });                                                                                  //update all properties, except for id
                    break;
                }
                data.SubmitChanges();
                action.TargetId = changedEvent.id;
            }
            catch (Exception e)
            {
                action.Type = DataActionTypes.Error;
            }
            return((ContentResult) new AjaxSaveResponse(action));
        }
        public ContentResult Save(int?id, FormCollection actionValues)
        {
            var action       = new DataAction(actionValues);
            var changedEvent = DHXEventsHelper.Bind <Event>(actionValues);

            if (this.Request.IsAuthenticated && changedEvent.user_id == (Guid)Membership.GetUser().ProviderUserKey)
            {
                DHXSchedulerDataContext data = new DHXSchedulerDataContext();
                try
                {
                    switch (action.Type)
                    {
                    case DataActionTypes.Insert:
                        changedEvent.room_id = data.Rooms.First().key;
                        data.Events.InsertOnSubmit(changedEvent);
                        break;

                    case DataActionTypes.Delete:
                        changedEvent = data.Events.SingleOrDefault(ev => ev.id == action.SourceId);
                        data.Events.DeleteOnSubmit(changedEvent);
                        break;

                    default:    // "update"
                        var eventToUpdate = data.Events.SingleOrDefault(ev => ev.id == action.SourceId);
                        DHXEventsHelper.Update(eventToUpdate, changedEvent, new List <string>()
                        {
                            "id"
                        });
                        break;
                    }
                    data.SubmitChanges();
                    action.TargetId = changedEvent.id;
                }
                catch (Exception a)
                {
                    action.Type = DataActionTypes.Error;
                }
            }
            else
            {
                action.Type = DataActionTypes.Error;
            }
            return(new AjaxSaveResponse(action));
        }