コード例 #1
0
ファイル: NewsController.cs プロジェクト: bogdanmacovei/NEDAW
        public ActionResult Edit(int id)
        {
            var result = _repository.FindById(id);

            if (result == null)
            {
                return(HttpNotFound());
            }

            var newResult = Mapper.Map <News, NewsDtoForUpdate>(result);

            var categoriesRepository = new GlobalRepository <NewsCategory>();
            var categories           = categoriesRepository.FindAll();

            var newsForm = new NewsForm
            {
                Title          = newResult.Title,
                Content        = newResult.Content,
                Image          = newResult.Image,
                NewsCategoryId = newResult.NewsCategoryId,
                NewsCategory   = newResult.NewsCategory,
                ModifiedBy     = newResult.ModifiedBy,
                ModifiedOn     = newResult.ModifiedOn,
                Categories     = GetAllCategories(categories),
                ViewMode       = Enums.ViewMode.Edit
            };

            return(View(newsForm));
        }
コード例 #2
0
 public GlobalController(Devices devices, GlobalRepository globalRepository, ICachingHandler cachingHandler, AreaManager areaManager)
 {
     _devices          = devices;
     _globalRepository = globalRepository;
     _cachingHandler   = cachingHandler;
     _areaManager      = areaManager;
 }
コード例 #3
0
ファイル: Program.cs プロジェクト: gavdraper/EFDisconnected
        public static CinemaDto LoadDisconnectAndModifyCinema()
        {
            var repo      = new GlobalRepository();
            var cinema    = repo.GetCinema();
            var cinemaDto = Mapper.Map <CinemaDto>(cinema);

            cinemaDto.Name = "Cinemagic Two";
            cinemaDto.ModifiedProperties.Add("Name");
            cinemaDto.Locations[0].Showings[0].Film.Name = "Jurassic Park";
            cinemaDto.Locations[0].Showings[0].Film.ModifiedProperties.Add("Name");
            cinemaDto.Locations.Add(new LocationDto()
            {
                Name = "Crawley", State = State.Added
            });
            cinemaDto.Locations.Add(new LocationDto()
            {
                Name = "Worthing", State = State.Added
            });
            cinemaDto.Locations[0].Showings.Add(new ShowingDto()
            {
                State  = State.Added,
                Start  = DateTime.Now,
                Film   = cinemaDto.Locations[0].Showings[0].Film,
                FilmId = cinemaDto.Locations[0].Showings[0].FilmId,
            });
            return(cinemaDto);
        }
コード例 #4
0
ファイル: NewsController.cs プロジェクト: bogdanmacovei/NEDAW
        public ActionResult Category(int id, string sortByTitle = "", string sortByDate = "desc")
        {
            var news = _repository.Find(n => n.NewsCategoryId == id);

            var result = news.Include("User").Include("NewsCategory");

            news = result.Where(n => n.Status == "Approved");

            IQueryable <News> newsLocal = news;

            if (!String.IsNullOrEmpty(sortByDate))
            {
                if (sortByDate == "asc")
                {
                    newsLocal = news.OrderBy(n => n.ModifiedOn);
                }
                else
                {
                    newsLocal = news.OrderByDescending(n => n.ModifiedOn);
                }

                news = newsLocal;
            }

            if (!String.IsNullOrEmpty(sortByTitle))
            {
                if (sortByTitle == "asc")
                {
                    newsLocal = news.OrderBy(n => n.Title);
                }
                else
                {
                    newsLocal = news.OrderByDescending(n => n.Title);
                }

                news = newsLocal;
            }


            GlobalRepository <NewsCategory> _categoriesRepository = new GlobalRepository <NewsCategory>();
            var categories = _categoriesRepository.Find(c => c.Id == id);

            var titlu = categories.Select(c => c.Name).FirstOrDefault();

            ViewBag.Name = titlu;

            ViewBag.Pages = (int)news.Count() / pageSize + 1;
            if (news.Count() % pageSize == 0)
            {
                ViewBag.Pages = ViewBag.Pages - 1;
            }

            var newsVM = new NewsVM
            {
                News = news
            };

            return(View(newsVM));
        }
コード例 #5
0
ファイル: NewsController.cs プロジェクト: bogdanmacovei/NEDAW
        public ActionResult New()
        {
            var categoriesRepository = new GlobalRepository <NewsCategory>();
            var categories           = categoriesRepository.FindAll();
            var newsForm             = new NewsForm
            {
                Categories = GetAllCategories(categories),
                ViewMode   = Enums.ViewMode.Add
            };

            return(View("Edit", newsForm));
        }
コード例 #6
0
        /// <summary>
        /// Create or get a global repository from the given entity
        /// </summary>
        /// <typeparam name="TEntity">The entity type</typeparam>
        /// <returns>A global repository</returns>
        public IGlobalRepository <TEntity> Entity <TEntity>()
            where TEntity : class
        {
            IGlobalRepository <TEntity> repo;

            if (this.globalRepos.TryGetValue(typeof(TEntity), out repo))
            {
                return((IGlobalRepository <TEntity>)repo);
            }
            else
            {
                // Instantiation des repositories pour chacun des contexts
                var repoGlobal = new GlobalRepository <TEntity>(this);
                this.globalRepos.Add(typeof(TEntity), repoGlobal);

                return(repoGlobal);
            }
        }
コード例 #7
0
ファイル: NewsController.cs プロジェクト: bogdanmacovei/NEDAW
        public ActionResult Show(int id)
        {
            var result = _repository.Find(n => n.Id == id);
            var news   = result.FirstOrDefault();

            ViewBag.showButtons = false;

            if (User.IsInRole("Editor") || User.IsInRole("Administrator"))
            {
                ViewBag.showButtons = true;
            }

            ViewBag.isAdmin     = User.IsInRole("Administrator");
            ViewBag.currentUser = User.Identity.GetUserId();

            var newResult = Mapper.Map <News, NewsDtoForUpdate>(news);

            var commentsRepository = new GlobalRepository <Comment>();
            var comments           = commentsRepository.Find(c => c.NewsId == news.Id).OrderByDescending(c => c.CreatedOn);

            var newsForm = new NewsForm
            {
                Id             = news.Id,
                Title          = news.Title,
                Content        = news.Content,
                Image          = news.Image,
                NewsCategoryId = news.NewsCategoryId,
                NewsCategory   = news.NewsCategory,
                ModifiedBy     = Guid.Parse(news.UserId),
                User           = news.User,
                ModifiedOn     = news.ModifiedOn,
                Comments       = comments.ToList()
            };

            return(View(newsForm));
        }
コード例 #8
0
ファイル: GlobalBusiness.cs プロジェクト: mh335776191/WeChat
 public static void AddGlobalError(string errortxt)
 {
     GlobalRepository _responsitory = new GlobalRepository();
     _responsitory.AddGlobalError(errortxt);
 }
コード例 #9
0
 public CategoryServices()
 {
     _categoryRepo = new GlobalRepository();
 }
コード例 #10
0
 public MapGenerator(GlobalRepository globalRepository)
 {
     GlobalRepository = globalRepository;
 }
コード例 #11
0
 public GlobalConfigurationController(GlobalRepository globalRepository)
 {
     _globalRepository = globalRepository;
 }
コード例 #12
0
 public ProductServices()
 {
     _productRepo = new GlobalRepository();
 }
コード例 #13
0
ファイル: NewsController.cs プロジェクト: bogdanmacovei/NEDAW
 public NewsController()
 {
     _repository = new GlobalRepository <News>();
 }
コード例 #14
0
 public CategoriesController()
 {
     _repository = new GlobalRepository <NewsCategory>();
 }
コード例 #15
0
 public CommentsController()
 {
     _repository = new GlobalRepository <Comment>();
 }
コード例 #16
0
 public BerlinMapGenerator(GlobalRepository globalRepository) : base(globalRepository)
 {
 }
コード例 #17
0
 public LondonMapGenerator(GlobalRepository globalRepository) : base(globalRepository)
 {
 }