public async Task <IActionResult> AddMultiple([FromBody] EventsVM model)
        {
            var calendarId = User.GetDefaultCalendarId();

            foreach (var eventVM in model.Events)
            {
                if (!DateTime.TryParseExact(eventVM.Start, "yyyy-MM-dd", null, DateTimeStyles.None, out DateTime parsedDate))
                {
                    return(BadRequest());
                }

                // Case: User is logged out, adds events and than logs in - front end sends everything
                // Maybe it already exist
                if (await _dbContext.CalendarEvents
                    .Where(ce => ce.DateTime.Date == parsedDate.Date)
                    .Where(ce => ce.CalendarId == calendarId)
                    .AnyAsync())
                {
                    continue;
                }

                _dbContext.CalendarEvents.Add(new CalendarEvent
                {
                    DateTime   = parsedDate,
                    Title      = eventVM.Title,
                    CalendarId = calendarId
                });
            }

            await _dbContext.SaveChangesAsync();

            return(Ok());
        }
Пример #2
0
        // GET: Event
        public ActionResult Index()
        {
            var vm = new EventsVM();

            vm.Events = _eops.UpcomingEvents();
            vm.Events = _eops.SetGMapUrls(vm.Events);
            return(View(vm));
        }
Пример #3
0
 public EventsVW()
 {
     InitializeComponent();
     Device.BeginInvokeOnMainThread(() => eventList.Opacity = 0);
     BindingContext          = new EventsVM();
     eventList.ItemSelected += (e, sender) =>
     {
         eventList.SelectedItem = null;
     };
 }
Пример #4
0
        public ActionResult TestEvents()
        {
            EventsVM        objP = new EventsVM();
            List <EventsVM> pe   = new List <EventsVM>();

            pe.Add(objP);

            var events = db.Events.OrderByDescending(x => x.EventId).ToList();

            ViewBag.Events = events;
            return(View(events));
        }
Пример #5
0
        public async Task <IActionResult> Index(int?page)
        {
            var      requestUrl = $"{BaseUrl}{apiUriEvents}/GetEvents";
            EventsVM events     = new EventsVM(_configuration);

            using (var client = new HttpClient())
            {
                client.BaseAddress = new Uri(requestUrl);
                HttpResponseMessage response = await client.GetAsync(requestUrl);

                if (response.StatusCode == HttpStatusCode.OK)
                {
                    events.Events = await response.Content.ReadAsAsync <IEnumerable <EventDTO> >();
                }
                ;
                events.PaginatedEvents = await PaginatedList <EventDTO> .CreateAsync(events.Events, page ?? 1, 2);
            };
            return(View(events));
        }
Пример #6
0
        protected override void OnAppearing()
        {
            var mapping = new ScheduleAppointmentMapping();

            mapping.SubjectMapping   = nameof(CEvent.Subject);
            mapping.StartTimeMapping = nameof(CEvent.FromDate);
            mapping.EndTimeMapping   = nameof(CEvent.ToDate);
            mapping.ColorMapping     = nameof(CEvent.EventColor);


            scheduler.AppointmentMapping = mapping;

            var vm = new EventsVM();

            scheduler.BindingContext = vm;

            scheduler.DataSource = vm.appointments;

            scheduler.ScheduleView = ScheduleView.MonthView;
            scheduler.MonthViewSettings.ShowAgendaView = true;

            base.OnAppearing();
        }