Exemple #1
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));
        }
Exemple #2
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));
        }