// GET: Community/Delete/5 public async Task <IActionResult> Delete(string id) { if (id == null) { return(NotFound()); } var community = await _context.Communities .FirstOrDefaultAsync(m => m.ID == id); if (community == null) { return(NotFound()); } var data = new AdsViewModel() { Community = community, Advertisements = await _context.Advertisements .Where(x => x.CommunityID == id).AsNoTracking().ToListAsync() }; return(View(data)); }
public IActionResult Ads(AdsViewModel adsViewModel) { string userId = null; var ads = _adService.Get(userId, adsViewModel.FilterAds.CategoryId, adsViewModel.FilterAds.Title); return(PartialView("_AdsTable", ads)); }
public IActionResult ManageAds(AdsViewModel adsViewModel) { var userId = User.GetUserId(); var ads = _adService.GetUserAds(userId, adsViewModel.FilterAds.CategoryId, adsViewModel.FilterAds.Title); return(PartialView("_ManageAds", ads)); }
public IActionResult MyAccount() { var db = new AdsDb(_connectionString); var vm = new AdsViewModel(); User CurrentUser = db.GetByEmail(User.Identity.Name); vm.Ads = db.GetAds().Where(a => a.UserId == CurrentUser.Id).ToList(); return(View(vm)); }
public IActionResult Ads() { var vm = new AdsViewModel { FilterAds = new FilterAds(), Ads = _adService.Get(), Categories = _categoryService.GetCategories() }; return(View(vm)); }
public IActionResult SearchAds(SearchAdsViewModel vM) { if (ModelState.IsValid) { // För gamla annonser ska tas bort // Begär att Businesslagret gör detta _businessLayer.DeleteOldAds(); AdsViewModel adsViewModel = new AdsViewModel(); // Begär att BusinessLagret söker annonser enligt angivna sökvillkor adsViewModel.CurrentAds = _businessLayer .SearchCurrentAds(vM.AdvTypeId, vM.EqTypeId, vM.SearchTitle, vM.SearchDescription, vM.SearchPlace); if (adsViewModel.CurrentAds.Count > 0) { adsViewModel.PageHeading = "Sökta Annonser"; } else { adsViewModel.PageHeading = "Inga Funna Annonser"; } return(View("IndexAds", adsViewModel)); } var advTypes = _businessLayer.GetAdvTypes(); vM.AdvTypeNames.Add(new SelectListItem { Text = "Alla Annonstyper", Value = "0" }); foreach (var advType in advTypes) { vM.AdvTypeNames.Add(new SelectListItem { Text = advType.Name, Value = advType.Id.ToString() }); } var eqTypes = _businessLayer.GetEquipmentTypes(); vM.EqTypeNames.Add(new SelectListItem { Text = "Alla Utrustningstyper", Value = "0" }); foreach (var eqType in eqTypes) { vM.EqTypeNames.Add(new SelectListItem { Text = eqType.Name, Value = eqType.Id.ToString() }); } return(View(vM)); }
public async Task <IActionResult> IndexOwnAds() { AdsViewModel viewModel = new AdsViewModel(); ApplicationUser user = await _userManager.FindByNameAsync(User.Identity.Name); // Begär att BusinessLagret ger mina aktuella annonser viewModel.CurrentAds = _businessLayer.GetUserAds(user.Id); return(View(viewModel)); }
public IActionResult Index(string id) { var community = _context.Communities.Where(m => m.ID == id).FirstOrDefault(); var adsView = new AdsViewModel(); adsView.Community = community; var adsCommunity = _context.AdvertisementCommunity.Where(m => m.CommunityID == id).Include(m => m.Advertisement); adsView.Advertisements = adsCommunity.Select(m => m.Advertisement); return(View(adsView)); }
public IActionResult ManageAds() { var userId = User.GetUserId(); var vm = new AdsViewModel { FilterAds = new FilterAds(), Ads = _adService.GetUserAds(userId), Categories = _categoryService.GetCategories() }; return(View(vm)); }
public IActionResult OnGet(int id) { ViewModel = adService.GetAdDetails(id); if (ViewModel != null) { foreach (var picture in ViewModel.Pictures) { ViewModel.PicturesPaths.Add(picture.Path); } return(null); } return(Redirect("/")); }
public IActionResult Index() { var db = new AdsDb(_connectionString); var vm = new AdsViewModel(); vm.Ads = db.GetAds(); vm.IsAuthenticated = User.Identity.IsAuthenticated; if (User.Identity.IsAuthenticated) { var email = User.Identity.Name; vm.CurrentUser = db.GetByEmail(email); } return(View(vm)); }
public async Task <IActionResult> Index(string id) { if (id == null) { return(NotFound()); } var data = new AdsViewModel() { Community = await _context.Communities.FindAsync(id), Advertisements = await _context.Advertisements .Where(x => x.CommunityID == id).OrderBy(x => x.Id) .AsNoTracking().ToListAsync() }; return(View(data)); }
public ActionResult Details(int adId) { var dbAd = db.Ads.Where(c => c.Id == adId).FirstOrDefault(); if (dbAd != null) { //fill the model here please AdsViewModel model = new AdsViewModel() { Id = dbAd.Id, By = dbAd.UserInfo.Username, Time = dbAd.CreationDate.Value, Area = dbAd.Area.Value, Description = dbAd.Description, Email = dbAd.EmailAddress, EnableDiscount = dbAd.AvailableDecrese.Value, Floar = dbAd.Floor.FloorName, PaymentType = dbAd.PaymentType.PaymentType1, Phone1 = dbAd.PhoneNumber1, Phone2 = dbAd.PhoneNumber2, Phone3 = dbAd.PhoneNumber3, Phone4 = dbAd.PhoneNumber4, Price = dbAd.Price.Value, Region = dbAd.Region.Name, Title = dbAd.Name, Type = dbAd.Type.Type1, img1Url1 = dbAd.Image1, img1Url2 = dbAd.Image2, img1Url3 = dbAd.Image3, img1Url4 = dbAd.Image4, Finishing = dbAd.Finishing.FininshName, videoUrl = dbAd.videoUrl }; return(View(model)); } return(View(new AdsViewModel())); }
// Visa alla annonser public IActionResult IndexAds() { // För gamla annonser ska tas bort // Begär att Businesslagret gör detta _businessLayer.DeleteOldAds(); AdsViewModel viewModel = new AdsViewModel(); // Begär att BusinessLagret ger alla aktuella annonser viewModel.CurrentAds = _businessLayer.GetCurrentAds(); if (viewModel.CurrentAds.Count > 0) { viewModel.PageHeading = "Alla Annonser"; } else { viewModel.PageHeading = "Inga Aktuella Annonser"; } return(View(viewModel)); }
public AdsController(IAdsRepository repo) { this._repo = repo; this.vm = new AdsViewModel(this._repo); }