Beispiel #1
0
        public ActionResult Edit(FormCollection collection)
        {
            try
            {
                var presentation = _mediaRepository.GetById(new Guid(collection["Id"]));

                var selectedGroups = collection["Groups[]"];
                var groups         = _screenGroupRepository.List();
                if (!String.IsNullOrEmpty(selectedGroups))
                {
                    foreach (var group in groups)
                    {
                        // Is the group checked
                        if (IsChecked(group, selectedGroups))
                        {
                            if (!presentation.Groups.Contains(group))
                            {
                                group.AddNewPresentation(presentation);
                                _screenGroupRepository.Update(group);
                            }
                        }
                        else
                        {
                            if (presentation.Groups.Contains(group))
                            {
                                group.DeletePresentation(presentation);
                                _screenGroupRepository.Update(group);
                            }
                        }
                    }
                }
                else
                {
                    foreach (var group in groups)
                    {
                        if (presentation.Groups.Contains(group))
                        {
                            group.DeletePresentation(presentation);
                            _screenGroupRepository.Update(group);
                        }
                    }
                }

                Request.Flash("success", Resources.Resources.Presentation + " " + Resources.Resources.Updated);

                return(RedirectToAction("Index"));
            }
            catch (Exception e)
            {
                Request.Flash("error", Resources.Resources.SevereError + ": " + e.Message);

                return(RedirectToAction("Index"));
            }
        }
Beispiel #2
0
        public IHttpActionResult Delete(Guid id)
        {
            try
            {
                var notification = _notificationRepository.GetById(id);

                var groups = _groupRepository.List();

                foreach (var group in groups)
                {
                    if (notification.Groups.Contains(group))
                    {
                        group.DeleteNotification(notification);
                        _groupRepository.Update(group);
                    }
                }

                _notificationRepository.Delete(id);
            }
            catch (Exception e)
            {
                return(InternalServerError(e));
            }

            return(Content(HttpStatusCode.NoContent, "Notification is succesfully removed."));
        }
        public ActionResult Create(FormCollection collection)
        {
            try
            {
                var notification = Notification.Create(collection["Title"]);
                notification.CreatedBy  = GetCurrentUser().User.ToString();
                notification.ModifiedBy = notification.CreatedBy;
                _notificationRepository.Insert(notification);

                var selectedGroups = collection["Groups[]"];
                var groups         = _screenGroupRepository.List();
                if (!String.IsNullOrEmpty(selectedGroups))
                {
                    foreach (var group in groups)
                    {
                        // Is the group checked
                        if (IsChecked(group, selectedGroups))
                        {
                            if (!notification.Groups.Contains(group))
                            {
                                group.AddNewNotification(notification);
                                _screenGroupRepository.Update(group);
                            }
                        }
                        else
                        {
                            if (notification.Groups.Contains(group))
                            {
                                group.DeleteNotification(notification);
                                _screenGroupRepository.Update(group);
                            }
                        }
                    }
                }
                else
                {
                    foreach (var group in groups)
                    {
                        if (notification.Groups.Contains(group))
                        {
                            group.DeleteNotification(notification);
                            _screenGroupRepository.Update(group);
                        }
                    }
                }

                Request.Flash("success", Resources.Resources.Notification + " " + Resources.Resources.Saved);

                return(RedirectToAction("Index"));
            }
            catch (Exception e)
            {
                Request.Flash("error", Resources.Resources.SevereError + ": " + e.Message);

                return(RedirectToAction("Index"));
            }
        }
Beispiel #4
0
        public ActionResult Edit(FormCollection collection)
        {
            try
            {
                var group = _screenGroupRepository.GetById(new Guid(collection["Id"]));

                var selectedPresentations = collection["Presentations[]"];
                var presentations         = _mediaRepository.List().Where(p => p.GetType() == typeof(Presentation));
                if (!String.IsNullOrEmpty(selectedPresentations))
                {
                    foreach (var presentation in presentations)
                    {
                        // Is the presentation checked
                        if (IsChecked(presentation, selectedPresentations))
                        {
                            if (!group.Media.Contains(presentation))
                            {
                                presentation.AddNewGroup(group);
                                _mediaRepository.Update(presentation);
                            }
                        }
                        else
                        {
                            if (group.Media.Contains(presentation))
                            {
                                presentation.DeleteGroup(group);
                                _mediaRepository.Update(presentation);
                            }
                        }
                    }
                }
                else
                {
                    foreach (var presentation in presentations)
                    {
                        if (group.Media.Contains(presentation))
                        {
                            presentation.DeleteGroup(group);
                            _mediaRepository.Update(presentation);
                        }
                    }
                }

                var selectedVideos = collection["Videos[]"];
                var videos         = _mediaRepository.List().Where(p => p.GetType() == typeof(Movie));
                if (!String.IsNullOrEmpty(selectedVideos))
                {
                    foreach (var video in videos)
                    {
                        // Is the presentation checked
                        if (IsChecked(video, selectedVideos))
                        {
                            if (!group.Media.Contains(video))
                            {
                                video.AddNewGroup(group);
                                _mediaRepository.Update(video);
                            }
                        }
                        else
                        {
                            if (group.Media.Contains(video))
                            {
                                video.DeleteGroup(group);
                                _mediaRepository.Update(video);
                            }
                        }
                    }
                }
                else
                {
                    foreach (var video in videos)
                    {
                        if (group.Media.Contains(video))
                        {
                            video.DeleteGroup(group);
                            _mediaRepository.Update(video);
                        }
                    }
                }

                group.Title      = collection["Title"];
                group.ModifiedBy = GetCurrentUser().User.ToString();

                _screenGroupRepository.Update(group);

                Request.Flash("success", Resources.Resources.Group + " " + Resources.Resources.Updated);

                return(RedirectToAction("Index"));
            }
            catch (Exception e)
            {
                Request.Flash("error", Resources.Resources.SevereError + ": " + e.Message);

                return(RedirectToAction("Index"));
            }
        }