public async Task AddAsync_ShouldReturnCorrectCountAsync() { await this.SeedData(this.context); var location = new WildLocationCreateViewModel() { Name = "new", }; var lastId = await this.wildLocationService.AddAsync(location); Assert.True(lastId == 3, "CreateMethod method does not work correctly"); }
public async Task <int> AddAsync(WildLocationCreateViewModel input) { var destination = new Location() { Name = input.Name, Lat = input.Lat, Lng = input.Lng, Type = WilderExperience.Data.Models.Enums.Type.Wild, }; await this.locationRepository.AddAsync(destination); await this.locationRepository.SaveChangesAsync(); return(destination.Id); }
public async Task <IActionResult> Add(WildLocationCreateViewModel input) { if (!this.ModelState.IsValid) { return(this.Redirect("All?status=error")); } if (this.wildLocationService.Exists(input.Name)) { return(this.Redirect("All?status=error")); } await this.wildLocationService.AddAsync(input); return(this.Redirect("All")); }