Ejemplo n.º 1
0
        public async Task <ActionResult> Create([Bind("Title")] TimelineViewModel vm)
        {
            if (ModelState.IsValid)
            {
                var timeline = await _repo.CreateTimelineAsync(vm.Title);

                _flash.Message("Timeline created!");

                // On success we return OK followed by the ID of the timeline just created.
                return(Ok("OK " + timeline.Id));
            }

            // Error - return view with validation errors showing.
            return(PartialView(vm));
        }
        public async Task <ActionResult> Create(string timelineId, [Bind("Title,Description,EventDateTime")] TimelineEventViewModel vm)
        {
            if (ModelState.IsValid)
            {
                TimelineEvent evt = await _repo.CreateTimelineEventAsync(
                    vm.Title,
                    vm.Description,
                    vm.EventDateTime,
                    vm.Location,
                    timelineId);

                _flash.Message($"Event '{evt.Title}' added!");

                return(Ok("OK " + evt.Id));
            }

            return(PartialView(vm));
        }
        public async Task <ActionResult> Upload(string eventId, List <IFormFile> files, string tab)
        {
            if (files.Any())
            {
                foreach (var file in files)
                {
                    // Create attachment and upload to AWS
                    await _repo.CreateAttachmentAsync(eventId, file.FileName, file.OpenReadStream());
                }

                var s = files.Count > 1 ? "s" : "";
                _flash.Message($"Uploaded {files.Count} attachment{s}");
            }
            else
            {
                _flash.Message("No attachments uploaded", FlashType.Info);
            }

            var @event = _repo.GetTimelineEvent(eventId);

            return(RedirectToAction("Details", "TimelineEvents", new { eventId, timelineId = @event.TimelineId, tab }));
        }