public async Task<bool> DeleteCountry(IGeoCountry country) { bool result = await repo.DeleteGeoZonesByCountry(country.Guid); result = await repo.DeleteCountry(country.Guid); return result; }
public async Task<bool> DeleteCountry(IGeoCountry country) { bool result = await repo.DeleteGeoZonesByCountry(country.Guid, CancellationToken.None); result = await repo.DeleteCountry(country.Guid, CancellationToken.None); return result; }
/// <summary> /// Persists a new instance of GeoCountry. /// </summary> /// <returns></returns> public async Task<bool> Save(IGeoCountry geoCountry) { if (geoCountry == null) { return false; } bool result; if (geoCountry.Guid == Guid.Empty) { geoCountry.Guid = Guid.NewGuid(); result = await dbGeoCountry.Create( geoCountry.Guid, geoCountry.Name, geoCountry.ISOCode2, geoCountry.ISOCode3); } else { result = await dbGeoCountry.Update( geoCountry.Guid, geoCountry.Name, geoCountry.ISOCode2, geoCountry.ISOCode3); } return result; }
public static GeoCountryViewModel FromIGeoCountry(IGeoCountry geoCountry) { GeoCountryViewModel model = new GeoCountryViewModel(); model.Id = geoCountry.Id; model.Name = geoCountry.Name; model.ISOCode2 = geoCountry.ISOCode2; model.ISOCode3 = geoCountry.ISOCode3; return model; }
public static GeoCountry FromIGeoCountry(IGeoCountry igeo) { GeoCountry country = new GeoCountry(); country.Guid = igeo.Guid; country.ISOCode2 = igeo.ISOCode2; country.ISOCode3 = igeo.ISOCode3; country.Name = igeo.Name; return country; }
public async Task<bool> Save(IGeoCountry geoCountry) { if (geoCountry == null) { return false; } GeoCountry country = GeoCountry.FromIGeoCountry(geoCountry); // convert from IGeoCountry dbContext.Countries.Add(country); int rowsAffected = await dbContext.SaveChangesAsync(); return rowsAffected > 0; }
public async Task<bool> Update( IGeoCountry geoCountry, CancellationToken cancellationToken = default(CancellationToken)) { if (geoCountry == null) { return false; } cancellationToken.ThrowIfCancellationRequested(); bool result = dbGeoCountry.Update( geoCountry.Guid, geoCountry.Name, geoCountry.ISOCode2, geoCountry.ISOCode3); return result; }
public async Task<bool> Update(IGeoCountry geoCountry, CancellationToken cancellationToken = default(CancellationToken)) { if (geoCountry == null) { return false; } GeoCountry country = GeoCountry.FromIGeoCountry(geoCountry); // convert from IGeoCountry bool tracking = dbContext.ChangeTracker.Entries<GeoCountry>().Any(x => x.Entity.Guid == country.Guid); if (!tracking) { dbContext.Countries.Update(country); } int rowsAffected = await dbContext.SaveChangesAsync(cancellationToken); return rowsAffected > 0; }
public async Task<bool> Add(IGeoCountry geoCountry, CancellationToken cancellationToken = default(CancellationToken)) { if (geoCountry == null) { return false; } GeoCountry country = GeoCountry.FromIGeoCountry(geoCountry); // convert from IGeoCountry if (country.Guid == Guid.Empty) { country.Guid = Guid.NewGuid(); } dbContext.Countries.Add(country); int rowsAffected = await dbContext.SaveChangesAsync(cancellationToken); return rowsAffected > 0; }
public async Task Add( IGeoCountry geoCountry, CancellationToken cancellationToken = default(CancellationToken) ) { ThrowIfDisposed(); cancellationToken.ThrowIfCancellationRequested(); if (geoCountry == null) throw new ArgumentException("geoCountry must not be null"); if (geoCountry.Id == Guid.Empty) throw new ArgumentException("geoCountry must have a non-empty id"); var country = GeoCountry.FromIGeoCountry(geoCountry); // convert from IGeoCountry dbContext.Countries.Add(country); int rowsAffected = await dbContext.SaveChangesAsync(cancellationToken) .ConfigureAwait(false); }
public async Task<bool> Add( IGeoCountry geoCountry, CancellationToken cancellationToken = default(CancellationToken)) { if (geoCountry == null) { return false; } cancellationToken.ThrowIfCancellationRequested(); if (geoCountry.Guid == Guid.Empty) { geoCountry.Guid = Guid.NewGuid(); } bool result = dbGeoCountry.Create( geoCountry.Guid, geoCountry.Name, geoCountry.ISOCode2, geoCountry.ISOCode3); return result; }
public async Task Update( IGeoCountry geoCountry, CancellationToken cancellationToken = default(CancellationToken)) { ThrowIfDisposed(); cancellationToken.ThrowIfCancellationRequested(); if (geoCountry == null) throw new ArgumentException("geoCountry must not be null"); if (geoCountry.Id == Guid.Empty) throw new ArgumentException("geoCountry must have a non-empty id"); var country = GeoCountry.FromIGeoCountry(geoCountry); // convert from IGeoCountry bool tracking = dbContext.ChangeTracker.Entries<GeoCountry>().Any(x => x.Entity.Id == country.Id); if (!tracking) { dbContext.Countries.Update(country); } int rowsAffected = await dbContext.SaveChangesAsync(cancellationToken) .ConfigureAwait(false); }
public async Task Update( IGeoCountry geoCountry, CancellationToken cancellationToken = default(CancellationToken)) { ThrowIfDisposed(); cancellationToken.ThrowIfCancellationRequested(); if (geoCountry == null) throw new ArgumentException("geoCountry must not be null"); if (geoCountry.Id == Guid.Empty) throw new ArgumentException("geoCountry must have a non-empty id"); //await EnsureProjectId().ConfigureAwait(false); var projectId = "default"; var country = GeoCountry.FromIGeoCountry(geoCountry); // convert from IGeoCountry await countryCommands.UpdateAsync( projectId, country.Id.ToString(), country, cancellationToken).ConfigureAwait(false); }
public Task<bool> Add(IGeoCountry geoCountry) { return repo.Add(geoCountry, CancellationToken.None); }
public Task<bool> Update(IGeoCountry geoCountry) { return repo.Update(geoCountry, CancellationToken.None); }
public async Task DeleteCountry(IGeoCountry country) { await commands.DeleteGeoZonesByCountry(country.Id, CancellationToken.None); await commands.DeleteCountry(country.Id, CancellationToken.None); }
public async Task Update(IGeoCountry geoCountry) { await commands.Update(geoCountry, CancellationToken.None); }
public async Task <bool> Update(IGeoCountry geoCountry) { return(await repo.Update(geoCountry, CancellationToken.None)); }
public async Task<bool> Save(IGeoCountry geoCountry) { return await repo.Save(geoCountry); }
public async Task <IActionResult> StateListPage( Guid?countryGuid, int pageNumber = 1, int pageSize = -1, int crp = 1, bool ajaxGrid = false, bool partial = false) { if (!countryGuid.HasValue) { return(RedirectToAction("CountryListPage")); } ViewBag.Title = "State List Administration"; int itemsPerPage = uiOptions.DefaultPageSize_StateList; if (pageSize > 0) { itemsPerPage = pageSize; } StateListPageViewModel model = new StateListPageViewModel(); IGeoCountry country = await dataManager.FetchCountry(countryGuid.Value); model.Country = GeoCountryViewModel.FromIGeoCountry(country); model.States = await dataManager.GetGeoZonePage(countryGuid.Value, pageNumber, itemsPerPage); model.Paging.CurrentPage = pageNumber; model.Paging.ItemsPerPage = itemsPerPage; model.Paging.TotalItems = await dataManager.GetGeoZoneCount(countryGuid.Value); model.CountryListReturnPageNumber = crp; // below we are just manipiulating the bread crumbs NavigationNodeAdjuster currentCrumbAdjuster = new NavigationNodeAdjuster(Request.HttpContext); currentCrumbAdjuster.KeyToAdjust = "StateListPage"; currentCrumbAdjuster.AdjustedText = model.Country.Name + " States"; currentCrumbAdjuster.AdjustedUrl = Request.Path.ToString() + "?countryGuid=" + country.Guid.ToString() + "&crp=" + crp.ToInvariantString(); currentCrumbAdjuster.ViewFilterName = NamedNavigationFilters.Breadcrumbs; // this is default but showing here for readers of code currentCrumbAdjuster.AddToContext(); NavigationNodeAdjuster countryListCrumbAdjuster = new NavigationNodeAdjuster(Request.HttpContext); countryListCrumbAdjuster.KeyToAdjust = "CountryListPage"; countryListCrumbAdjuster.AdjustedUrl = Request.Path.ToString().Replace("StateListPage", "CountryListPage") + "?pageNumber=" + crp.ToInvariantString(); countryListCrumbAdjuster.AddToContext(); if (ajaxGrid) { return(PartialView("StateListGridPartial", model)); } if (partial) { return(PartialView("StateListPagePartial", model)); } return(View(model)); }
private void LoadFromReader(DbDataReader reader, IGeoCountry geoCountry) { geoCountry.Guid = new Guid(reader["Guid"].ToString()); geoCountry.Name = reader["Name"].ToString(); geoCountry.ISOCode2 = reader["ISOCode2"].ToString(); geoCountry.ISOCode3 = reader["ISOCode3"].ToString(); }
public async Task Add(IGeoCountry geoCountry) { await commands.Add(geoCountry, CancellationToken.None); }
public async Task Add(IGeoCountry geoCountry) { if (geoCountry.Id == Guid.Empty) geoCountry.Id = Guid.NewGuid(); await commands.Add(geoCountry, CancellationToken.None); }
public async Task Update(IGeoCountry geoCountry) { await commands.Update(geoCountry, 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 DeleteCountry(IGeoCountry country) { await commands.DeleteGeoZonesByCountry(country.Id, CancellationToken.None); await commands.DeleteCountry(country.Id, CancellationToken.None); }
public async Task <bool> Save(IGeoCountry geoCountry) { return(await repo.Save(geoCountry)); }