Beispiel #1
0
        public IActionResult AddPictureEvent(AddPictureEventViewModel addPictureEventViewModel)
        {
            if (ModelState.IsValid)
            {
                string _stackID = addPictureEventViewModel.StackID;

                int eventID = addPictureEventViewModel.EventID;

                List <int> pictureIDs = addPictureEventViewModel.PictureIDs;

                foreach (var pictureID in pictureIDs)
                {
                    PictureEvent pictureEvent = new PictureEvent()
                    {
                        PictureID = pictureID,
                        EventID   = eventID
                    };

                    context.PictureEvents.Add(pictureEvent);
                }

                context.SaveChanges();

                return(Redirect(string.Format("/Picture/AddPIctureEvent?StackID={0}", _stackID)));
            }

            return(View(addPictureEventViewModel));
        }
Beispiel #2
0
        public IActionResult AddPictureEvent(string stackID, string sortOrder)
        {
            ViewBag.Sorting = sortOrder;

            var selectAllPicturesWithoutEvent = provider.SelectAllPicturesWhithoutEvent();

            var slectAllPictureWithoutEventNotYetClassified = selectAllPicturesWithoutEvent
                                                              .Where(p => p.PictureStackIsClassified == false)
                                                              .AsQueryable();

            if (stackID != null)
            {
                var selectAllPictureOfAStackWithoutEvent = Sorting(sortOrder, slectAllPictureWithoutEventNotYetClassified)
                                                           .Where(p => p.PictureStackID == int.Parse(stackID))
                                                           .AsQueryable();

                string _stackID = stackID;

                var events = context.Events.Include(p => p.EventType).ToList();

                var pictureIDs = selectAllPictureOfAStackWithoutEvent.Select(p => p.PictureID).ToList();

                AddPictureEventViewModel addPictureEventViewModel =
                    new AddPictureEventViewModel
                    (
                        selectAllPictureOfAStackWithoutEvent.ToList(),
                        events,
                        pictureIDs,
                        _stackID
                    );

                return(View(addPictureEventViewModel));
            }

            else
            {
                var selectAllPictureOfAStackWithoutEvent = Sorting(sortOrder, slectAllPictureWithoutEventNotYetClassified)
                                                           .AsQueryable();

                string _stackID = stackID;

                var events = context.Events.Include(p => p.EventType).ToList();

                var pictureIDs = selectAllPictureOfAStackWithoutEvent.Select(p => p.PictureID).ToList();

                AddPictureEventViewModel addPictureEventViewModel =
                    new AddPictureEventViewModel
                    (
                        selectAllPictureOfAStackWithoutEvent.ToList(),
                        events,
                        pictureIDs,
                        _stackID
                    );

                return(View(addPictureEventViewModel));
            }
        }