public async Task <IActionResult> DeleteConfirmed(LocationDetailsVM locationVM) { var locationToDelete = _mapper.Map <Location>(locationVM); var location = await _locationService.DeleteAsync(locationToDelete); return(RedirectToAction(nameof(Index))); }
public async Task <IActionResult> Edit([Bind("Id,Street,StreetNumber,City")] LocationDetailsVM locationVM) { if (ModelState.IsValid) //is het valid? { var locationToUpdate = _mapper.Map <Location>(locationVM); var updatedLocation = await _locationService.UpdateAsync(locationToUpdate); var locationVMToReturn = _mapper.Map <LocationDetailsVM>(updatedLocation); return(RedirectToAction(nameof(Index))); } return(View(locationVM)); }
public async Task <IActionResult> Index(string searchString) { var locations = await _locationService.GetListAsync(); if (!string.IsNullOrEmpty(searchString)) { locations = locations.Where(s => s.Street.Contains(searchString) || s.City.Contains(searchString)); } var locationVM = new LocationDetailsVM { Locations = locations.ToList() }; return(View(locationVM)); }
public CreateTests() { _mockRepo = new Mock <ILocationRepository>(); var mapperConfig = new MapperConfiguration(c => { c.AddProfile(new Maps()); }); var mapper = mapperConfig.CreateMapper(); var campRepo = new Mock <ICampaignRepository>(); var npcRepo = new Mock <INpcRepository>(); var logger = new Mock <ILogger <LocationsController> >(); _sut = new LocationsController(_mockRepo.Object, logger.Object, mapper, campRepo.Object, npcRepo.Object); _newLocation = new LocationDetailsVM { LocationName = "test", LocationType = "test", LocationInventory = "test", Description = "test", Notes = "test", CampaignId = 1 }; }