public async Task Update( IGeoZone geoZone, CancellationToken cancellationToken = default(CancellationToken)) { ThrowIfDisposed(); cancellationToken.ThrowIfCancellationRequested(); if (geoZone == null) { throw new ArgumentException("geoZone must not be null"); } if (geoZone.Id == Guid.Empty) { throw new ArgumentException("geoZone must have a non-empty id"); } if (geoZone.CountryId == Guid.Empty) { throw new ArgumentException("geoZone must have a non-empty CountryId"); } await EnsureProjectId().ConfigureAwait(false); var state = GeoZone.FromIGeoZone(geoZone); // convert from IGeoZone await stateCommands.UpdateAsync( projectId, state.Id.ToString(), state, cancellationToken).ConfigureAwait(false); }
public async Task Update( IGeoZone geoZone, CancellationToken cancellationToken = default(CancellationToken)) { ThrowIfDisposed(); cancellationToken.ThrowIfCancellationRequested(); if (geoZone == null) { throw new ArgumentException("geoZone must not be null"); } if (geoZone.Id == Guid.Empty) { throw new ArgumentException("geoZone must have a non-empty id"); } if (geoZone.CountryId == Guid.Empty) { throw new ArgumentException("geoZone must have a non-empty CountryId"); } var state = GeoZone.FromIGeoZone(geoZone); // convert from IGeoZone bool tracking = dbContext.ChangeTracker.Entries <GeoZone>().Any(x => x.Entity.Id == state.Id); if (!tracking) { dbContext.States.Update(state); } int rowsAffected = await dbContext.SaveChangesAsync(cancellationToken) .ConfigureAwait(false); }
public async Task <IActionResult> StateDelete( Guid countryGuid, Guid guid, int crp = 1, int returnPageNumber = 1) { IGeoZone state = await dataManager.FetchGeoZone(guid); if (state != null) { bool result = await dataManager.DeleteGeoZone(state); if (result) { this.AlertWarning(string.Format( "The state <b>{0}</b> was successfully deleted.", state.Name) , true); } } return(RedirectToAction("StateListPage", new { countryGuid = countryGuid, crp = crp, pageNumber = returnPageNumber })); }
public async Task <bool> Save(IGeoZone geoZone, CancellationToken cancellationToken = default(CancellationToken)) { if (geoZone == null) { return(false); } GeoZone state = GeoZone.FromIGeoZone(geoZone); // convert from IGeoZone if (geoZone.Guid == Guid.Empty) { state.Guid = Guid.NewGuid(); dbContext.States.Add(state); } else { bool tracking = dbContext.ChangeTracker.Entries <GeoZone>().Any(x => x.Entity.Guid == state.Guid); if (!tracking) { dbContext.States.Update(state); } } int rowsAffected = await dbContext.SaveChangesAsync(cancellationToken); return(rowsAffected > 0); }
/// <summary> /// Persists a new instance of GeoZone. /// </summary> /// <returns></returns> public async Task <bool> Save(IGeoZone geoZone, CancellationToken cancellationToken = default(CancellationToken)) { if (geoZone == null) { return(false); } cancellationToken.ThrowIfCancellationRequested(); bool result; if (geoZone.Guid == Guid.Empty) { geoZone.Guid = Guid.NewGuid(); result = dbGeoZone.Create( geoZone.Guid, geoZone.CountryGuid, geoZone.Name, geoZone.Code); } else { result = dbGeoZone.Update( geoZone.Guid, geoZone.CountryGuid, geoZone.Name, geoZone.Code); } return(result); }
/// <summary> /// Persists a new instance of GeoZone. /// </summary> /// <returns></returns> public async Task <bool> Save(IGeoZone geoZone) { if (geoZone == null) { return(false); } bool result = false; if (geoZone.Guid == Guid.Empty) { geoZone.Guid = Guid.NewGuid(); result = await dbGeoZone.Create( geoZone.Guid, geoZone.CountryGuid, geoZone.Name, geoZone.Code); } else { result = await dbGeoZone.Update( geoZone.Guid, geoZone.CountryGuid, geoZone.Name, geoZone.Code); } return(result); }
private void LoadFromReader(DbDataReader reader, IGeoZone geoZone) { geoZone.Guid = new Guid(reader["Guid"].ToString()); geoZone.CountryGuid = new Guid(reader["CountryGuid"].ToString()); geoZone.Name = reader["Name"].ToString(); geoZone.Code = reader["Code"].ToString(); }
public async Task Add(IGeoZone geoZone) { if (geoZone.Id == Guid.Empty) { geoZone.Id = Guid.NewGuid(); } await commands.Add(geoZone, CancellationToken.None); }
public static GeoZoneViewModel FromIGeoZone(IGeoZone geoZone) { GeoZoneViewModel model = new GeoZoneViewModel(); model.Id = geoZone.Id; model.CountryId = geoZone.CountryId; model.Name = geoZone.Name; model.Code = geoZone.Code; return model; }
public static GeoZoneViewModel FromIGeoZone(IGeoZone geoZone) { GeoZoneViewModel model = new GeoZoneViewModel(); model.Id = geoZone.Id; model.CountryId = geoZone.CountryId; model.Name = geoZone.Name; model.Code = geoZone.Code; return(model); }
public static GeoZone FromIGeoZone(IGeoZone igeo) { GeoZone state = new GeoZone(); state.Guid = igeo.Guid; state.CountryGuid = igeo.CountryGuid; state.Code = igeo.Code; state.Name = igeo.Name; return state; }
public static GeoZone FromIGeoZone(IGeoZone igeo) { GeoZone state = new GeoZone(); state.Guid = igeo.Guid; state.CountryGuid = igeo.CountryGuid; state.Code = igeo.Code; state.Name = igeo.Name; return(state); }
public static GeoZone FromIGeoZone(IGeoZone igeo) { GeoZone state = new GeoZone { Id = igeo.Id, CountryId = igeo.CountryId, Code = igeo.Code, Name = igeo.Name }; return(state); }
public async Task Add( IGeoZone geoZone, CancellationToken cancellationToken = default(CancellationToken)) { ThrowIfDisposed(); cancellationToken.ThrowIfCancellationRequested(); if (geoZone == null) throw new ArgumentException("geoZone must not be null"); if (geoZone.Id == Guid.Empty) throw new ArgumentException("geoZone must have a non-empty id"); var state = GeoZone.FromIGeoZone(geoZone); // convert from IGeoZone dbContext.States.Add(state); int rowsAffected = await dbContext.SaveChangesAsync(cancellationToken) .ConfigureAwait(false); }
public async Task <bool> Update( IGeoZone geoZone, CancellationToken cancellationToken = default(CancellationToken)) { if (geoZone == null) { return(false); } cancellationToken.ThrowIfCancellationRequested(); bool result = await dbGeoZone.Update( geoZone.Guid, geoZone.CountryGuid, geoZone.Name, geoZone.Code, cancellationToken); return(result); }
public async Task <bool> Add(IGeoZone geoZone, CancellationToken cancellationToken = default(CancellationToken)) { if (geoZone == null) { return(false); } GeoZone state = GeoZone.FromIGeoZone(geoZone); // convert from IGeoZone if (geoZone.Guid == Guid.Empty) { state.Guid = Guid.NewGuid(); } dbContext.States.Add(state); int rowsAffected = await dbContext.SaveChangesAsync(cancellationToken); return(rowsAffected > 0); }
public async Task Add( IGeoZone geoZone, CancellationToken cancellationToken = default(CancellationToken)) { ThrowIfDisposed(); cancellationToken.ThrowIfCancellationRequested(); if (geoZone == null) { throw new ArgumentException("geoZone must not be null"); } if (geoZone.Id == Guid.Empty) { throw new ArgumentException("geoZone must have a non-empty id"); } var state = GeoZone.FromIGeoZone(geoZone); // convert from IGeoZone dbContext.States.Add(state); int rowsAffected = await dbContext.SaveChangesAsync(cancellationToken) .ConfigureAwait(false); }
/// <summary> /// Persists a new instance of GeoZone. /// </summary> /// <returns></returns> public async Task<bool> Save(IGeoZone geoZone) { if (geoZone == null) { return false; } bool result; if (geoZone.Guid == Guid.Empty) { geoZone.Guid = Guid.NewGuid(); result = await dbGeoZone.Create( geoZone.Guid, geoZone.CountryGuid, geoZone.Name, geoZone.Code); } else { result = await dbGeoZone.Update( geoZone.Guid, geoZone.CountryGuid, geoZone.Name, geoZone.Code); } return result; }
public async Task Update( IGeoZone geoZone, CancellationToken cancellationToken = default(CancellationToken)) { ThrowIfDisposed(); cancellationToken.ThrowIfCancellationRequested(); if (geoZone == null) throw new ArgumentException("geoZone must not be null"); if (geoZone.Id == Guid.Empty) throw new ArgumentException("geoZone must have a non-empty id"); if (geoZone.CountryId == Guid.Empty) throw new ArgumentException("geoZone must have a non-empty CountryId"); //await EnsureProjectId().ConfigureAwait(false); var projectId = "default"; var state = GeoZone.FromIGeoZone(geoZone); // convert from IGeoZone await stateCommands.UpdateAsync( projectId, state.Id.ToString(), state, cancellationToken).ConfigureAwait(false); }
public Task<bool> DeleteGeoZone(IGeoZone geoZone) { return repo.DeleteGeoZone(geoZone.Guid, CancellationToken.None); }
public async Task Add(IGeoZone geoZone) { await commands.Add(geoZone, CancellationToken.None); }
public async Task <bool> DeleteGeoZone(IGeoZone geoZone) { return(await repo.DeleteGeoZone(geoZone.Guid)); }
public async Task Update(IGeoZone geoZone) { await commands.Update(geoZone, CancellationToken.None); }
public Task<bool> Add(IGeoZone geoZone) { return repo.Add(geoZone, CancellationToken.None); }
public async Task<bool> Add(IGeoZone geoZone, CancellationToken cancellationToken = default(CancellationToken)) { if (geoZone == null) { return false; } GeoZone state = GeoZone.FromIGeoZone(geoZone); // convert from IGeoZone if (geoZone.Guid == Guid.Empty) { state.Guid = Guid.NewGuid(); } dbContext.States.Add(state); int rowsAffected = await dbContext.SaveChangesAsync(cancellationToken); return rowsAffected > 0; }
public async Task<bool> Add( IGeoZone geoZone, CancellationToken cancellationToken = default(CancellationToken)) { if (geoZone == null) { return false; } cancellationToken.ThrowIfCancellationRequested(); if (geoZone.Guid == Guid.Empty) { geoZone.Guid = Guid.NewGuid(); } bool result = dbGeoZone.Create( geoZone.Guid, geoZone.CountryGuid, geoZone.Name, geoZone.Code); return result; }
public Task <bool> DeleteGeoZone(IGeoZone geoZone) { return(repo.DeleteGeoZone(geoZone.Guid, CancellationToken.None)); }
public Task <bool> Update(IGeoZone geoZone) { return(repo.Update(geoZone, CancellationToken.None)); }
public Task <bool> Add(IGeoZone geoZone) { return(repo.Add(geoZone, CancellationToken.None)); }
public async Task <bool> DeleteGeoZone(IGeoZone geoZone) { return(await repo.DeleteGeoZone(geoZone.Guid, CancellationToken)); }
public async Task <bool> Save(IGeoZone geoZone) { return(await repo.Save(geoZone, CancellationToken)); }
public async Task<bool> Update( IGeoZone geoZone, CancellationToken cancellationToken = default(CancellationToken)) { if (geoZone == null) { return false; } GeoZone state = GeoZone.FromIGeoZone(geoZone); // convert from IGeoZone bool tracking = dbContext.ChangeTracker.Entries<GeoZone>().Any(x => x.Entity.Guid == state.Guid); if (!tracking) { dbContext.States.Update(state); } int rowsAffected = await dbContext.SaveChangesAsync(cancellationToken); return rowsAffected > 0; }
public async Task <bool> Save(IGeoZone geoZone) { return(await repo.Save(geoZone)); }
public async Task<bool> Update( IGeoZone geoZone, CancellationToken cancellationToken = default(CancellationToken)) { if (geoZone == null) { return false; } cancellationToken.ThrowIfCancellationRequested(); bool result = dbGeoZone.Update( geoZone.Guid, geoZone.CountryGuid, geoZone.Name, geoZone.Code); return result; }
public async Task<bool> DeleteGeoZone(IGeoZone geoZone) { return await repo.DeleteGeoZone(geoZone.Guid); }
public Task<bool> Update(IGeoZone geoZone) { return repo.Update(geoZone, CancellationToken.None); }
public async Task Add(IGeoZone geoZone) { if (geoZone.Id == Guid.Empty) geoZone.Id = Guid.NewGuid(); await commands.Add(geoZone, CancellationToken.None); }
public async Task<bool> Save(IGeoZone geoZone) { if (geoZone == null) { return false; } GeoZone state = GeoZone.FromIGeoZone(geoZone); // convert from IGeoZone dbContext.States.Add(state); int rowsAffected = await dbContext.SaveChangesAsync(); return rowsAffected > 0; }
public async Task DeleteGeoZone(IGeoZone geoZone) { await commands.DeleteGeoZone(geoZone.Id, CancellationToken.None); }
public async Task <IActionResult> StateEdit( Guid countryGuid, Guid?guid, int crp = 1, int returnPageNumber = 1 ) { if (countryGuid == Guid.Empty) { return(RedirectToAction("CountryListPage")); } //int returnPage = 1; //if (returnPageNumber.HasValue) { returnPage = returnPageNumber.Value; } ViewBag.Title = "Edit State"; GeoZoneViewModel model; if ((guid.HasValue) && (guid.Value != Guid.Empty)) { IGeoZone state = await dataManager.FetchGeoZone(guid.Value); if ((state != null) && (state.CountryGuid == countryGuid)) { model = GeoZoneViewModel.FromIGeoZone(state); model.Heading = "Edit State"; } else { // invalid guid provided return(RedirectToAction("CountryListPage", new { pageNumber = crp })); } } else { model = new GeoZoneViewModel(); model.Heading = "Create New State"; model.CountryGuid = countryGuid; } model.ReturnPageNumber = returnPageNumber; model.CountryListReturnPageNumber = crp; IGeoCountry country = await dataManager.FetchCountry(countryGuid); model.Country = GeoCountryViewModel.FromIGeoCountry(country); NavigationNodeAdjuster currentCrumbAdjuster = new NavigationNodeAdjuster(Request.HttpContext); currentCrumbAdjuster.KeyToAdjust = "StateEdit"; currentCrumbAdjuster.AdjustedText = model.Heading; currentCrumbAdjuster.ViewFilterName = NamedNavigationFilters.Breadcrumbs; // this is default but showing here for readers of code currentCrumbAdjuster.AddToContext(); //var node = SiteMaps.Current.FindSiteMapNodeFromKey("StateEdit"); //if (node != null) //{ // node.Title = model.Heading; // var parent = node.ParentNode; // if (parent != null) // { // parent.Title = model.Country.Name + " States"; // } //} return(View(model)); }
public async Task Update( IGeoZone geoZone, CancellationToken cancellationToken = default(CancellationToken)) { ThrowIfDisposed(); cancellationToken.ThrowIfCancellationRequested(); if (geoZone == null) throw new ArgumentException("geoZone must not be null"); if (geoZone.Id == Guid.Empty) throw new ArgumentException("geoZone must have a non-empty id"); if (geoZone.CountryId == Guid.Empty) throw new ArgumentException("geoZone must have a non-empty CountryId"); var state = GeoZone.FromIGeoZone(geoZone); // convert from IGeoZone bool tracking = dbContext.ChangeTracker.Entries<GeoZone>().Any(x => x.Entity.Id == state.Id); if (!tracking) { dbContext.States.Update(state); } int rowsAffected = await dbContext.SaveChangesAsync(cancellationToken) .ConfigureAwait(false); }
public async Task<bool> Save(IGeoZone geoZone) { return await repo.Save(geoZone); }