public void SaveEntity(AddEditRegionBindingModel model) { var region = this.Mapper.Map <Landmarks.Models.Region>(model); this.DbContext.Attach(region).State = EntityState.Modified; this.DbContext.SaveChanges(); }
public void CreateRegion(AddEditRegionBindingModel regionModel) { var region = this.Mapper.Map <AddEditRegionBindingModel, Region>(regionModel); this.DbContext.Regions.Add(region); this.DbContext.SaveChangesAsync(); }
public void CreateRegion_WithValidModel_SholdSaveInDb() { //Arange var service = new RegionService(this._dbContext, this._mapper, null); var validRegion = new AddEditRegionBindingModel { Id = 1, Name = "Region", Area = 1478 }; //Act service.CreateRegion(validRegion); //Assert Assert.AreEqual(1, this._dbContext.Regions.Count()); }
public IActionResult OnGet(int?id) { if (id == null) { return(NotFound()); } var region = this._service.GetRegion(id.Value); if (region == null) { return(NotFound()); } this.EditCategoryBindingModel = this._mapper.Map <AddEditRegionBindingModel>(region); return(this.Page()); }