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)); }
public GlobalController(Devices devices, GlobalRepository globalRepository, ICachingHandler cachingHandler, AreaManager areaManager) { _devices = devices; _globalRepository = globalRepository; _cachingHandler = cachingHandler; _areaManager = areaManager; }
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); }
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)); }
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)); }
/// <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); } }
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)); }
public static void AddGlobalError(string errortxt) { GlobalRepository _responsitory = new GlobalRepository(); _responsitory.AddGlobalError(errortxt); }
public CategoryServices() { _categoryRepo = new GlobalRepository(); }
public MapGenerator(GlobalRepository globalRepository) { GlobalRepository = globalRepository; }
public GlobalConfigurationController(GlobalRepository globalRepository) { _globalRepository = globalRepository; }
public ProductServices() { _productRepo = new GlobalRepository(); }
public NewsController() { _repository = new GlobalRepository <News>(); }
public CategoriesController() { _repository = new GlobalRepository <NewsCategory>(); }
public CommentsController() { _repository = new GlobalRepository <Comment>(); }
public BerlinMapGenerator(GlobalRepository globalRepository) : base(globalRepository) { }
public LondonMapGenerator(GlobalRepository globalRepository) : base(globalRepository) { }