Пример #1
0
            protected override void OnTimeRangeSelected(TimeRangeSelectedArgs e)
            {
                CalendarEventsDataContext db = new CalendarEventsDataContext();

                try
                {
                    if (Controller.User.Identity.Name != null)
                    {
                        var toBeCreated = new CarWashMonthlyEvent
                        {
                            EventStart = e.Start,
                            EventEnd   = e.End,
                            Text       = (string)e.Data["eventName"],
                            UserName   = Controller.User.Identity.Name
                        };
                        db.CarWashMonthlyEvents.InsertOnSubmit(toBeCreated);
                        db.SubmitChanges();
                        Update(Events);
                    }
                    else
                    {
                        throw new AuthenticationException("Musisz być zalogowany aby zarezerwować termin");
                    }
                }
                catch (Exception ex)
                {
                    Controller.ModelState.AddModelError("ErrorMessage", ex);
                }
            }
Пример #2
0
            protected override void OnEventMove(EventMoveArgs e)
            {
                CalendarEventsDataContext db = new CalendarEventsDataContext();

                try
                {
                    var toBeResized =
                        (from ev in db.CarWashMonthlyEvents where ev.Id == Convert.ToInt32(e.Id) select ev).First();

                    if (toBeResized.UserName == Controller.User.Identity.Name)
                    {
                        toBeResized.EventStart = e.NewStart;
                        toBeResized.EventEnd   = e.NewEnd;
                        db.SubmitChanges();
                        Update();
                    }
                    else
                    {
                        throw new AuthenticationException("Nie masz uprawnień do zmiany tego obiektu");
                    }
                }
                catch (Exception ex)
                {
                    Controller.ModelState.AddModelError("ErrorMessage", ex);
                }
            }
Пример #3
0
            protected override void OnInit(InitArgs initArgs)
            {
                CalendarEventsDataContext db = new CalendarEventsDataContext();

                //Events = from ev in _db.CarWashMonthlyEvents select ev;

                //DataIdField = "Id";
                //DataTextField = "Text";
                //DataStartField = "EventStart";
                //DataEndField = "EventEnd";
                //DataUserField = "UserName";

                Update();
            }
Пример #4
0
            protected override void OnFinish()
            {
                CalendarEventsDataContext db = new CalendarEventsDataContext();

                // only load the data if an update was requested by an Update() call
                if (UpdateType == CallBackUpdateType.None)
                {
                    return;
                }

                Events = from ev in db.CarWashMonthlyEvents select ev;

                DataIdField    = "Id";
                DataTextField  = "Text";
                DataStartField = "EventStart";
                DataEndField   = "EventEnd";
                DataUserField  = "UserName";
            }