Beispiel #1
0
        public ActionResult Save(int?id, FormCollection actionValues)
        {
            var action = new DataAction(actionValues);

            try
            {
                var     changedEvent = DHXEventsHelper.Bind <HolidayVM>(actionValues);
                holiday h            = new holiday {
                    holidayId = changedEvent.holidayId,
                    startDate = changedEvent.startDate, endDate = changedEvent.endDate, name = changedEvent.name
                };
                switch (action.Type)
                {
                case DataActionTypes.Insert:
                    hs.Add(h);
                    hs.Commit();
                    break;

                case DataActionTypes.Delete:
                    hs.Delete(holiday => holiday.holidayId == changedEvent.holidayId);
                    hs.Commit();
                    break;

                case DataActionTypes.Update:
                    hs.Update(h);
                    hs.Commit();
                    break;

                default:
                    break;
                }
                action.TargetId = changedEvent.holidayId;
            }
            catch (Exception a)
            {
                action.Type = DataActionTypes.Error;
            }

            return(new AjaxSaveResponse(action));
        }