public async Task <IActionResult> Put(string id, [FromBody] CountryForm model) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var country = await _countryRepository.Query().FirstOrDefaultAsync(x => x.Id == id); if (country == null) { return(NotFound()); } country.Name = model.Name; country.Code3 = model.Code3; country.IsShippingEnabled = model.IsShippingEnabled; country.IsBillingEnabled = model.IsBillingEnabled; country.IsCityEnabled = model.IsCityEnabled; country.IsZipCodeEnabled = model.IsZipCodeEnabled; country.IsDistrictEnabled = model.IsDistrictEnabled; await _countryRepository.SaveChangesAsync(); return(Accepted()); }
public IActionResult Create(CountryForm form) { if (_sessionManager.User is not null) { try { if (ModelState.IsValid) { Country c = new Country { Ctry = form.Ctry, ISO = form.ISO, IsEU = form.IsEU }; _countryService.Add(c); return(RedirectToAction("index")); } } catch (Exception ex) { ModelState.AddModelError("", ex.Message); //ViewBag.Error = ex.Message; } return(View()); } else { return(RedirectToAction("Login", "Auth")); } }
private void barButtonCountry_ItemClick(object sender, ItemClickEventArgs e) { CountryForm xform1 = new CountryForm(_FlexSys) { MdiParent = this }; xform1.Show(); }
private void mnuManageExit_Click(object sender, EventArgs e) { this.Hide(); UserForm = null; AddressForm = null; CountryForm = null; StateForm = null; reLogin.Call(); this.Close(); }
public IActionResult Edit(CountryForm model) { if (ModelState.IsValid) { var result = _service.UpdateFromDto <CountryForm>(model.Id, model); if (result.Succeeded) { return(RedirectToAction("Index")); } ModelState.AddResultErrors(result); } return(View(model)); }
private void mnuManageCountry_Click(object sender, EventArgs e) { if (CountryForm == null) { CountryForm = new CountryForm(); CountryForm.Show(); CountryForm.MdiParent = this; CountryForm.FormClosing += CountryForm_FormClosing; } else { CountryForm.Activate(); } }
private void AddCountry_Click(object sender, EventArgs e) { try { var dataProvider = AppContext.TableManager.Countries.RowProvider; var form = new CountryForm(dataProvider); form.Show(Owner); } catch (Exception ex) { this.ShowError(ex.Message); } }
public async Task <ActionResult <CreateCountryResponse> > Post( [FromBody] CountryForm Country, CancellationToken cancellationToken ) { var request = new CreateCountry() { RequestId = this.GetRequestId(), Country = Country, }; var response = await _mediator.Send(request, cancellationToken); return(Ok(response)); }
public async Task <IActionResult> Post([FromBody] CountryForm model) { if (ModelState.IsValid) { var country = new Country { Name = model.Name, Code2 = model.Code2, Code3 = model.Code3, IsBillingEnabled = model.IsBillingEnabled, IsShippingEnabled = model.IsShippingEnabled }; _countryRepository.Add(country); await _countryRepository.SaveChangesAsync(); return(CreatedAtAction(nameof(Get), new { id = country.Id }, null)); } return(BadRequest(ModelState)); }
public IActionResult Upd([FromBody] CountryForm ctry) { try { if (ctry is null) { throw new ArgumentNullException("Country Empty (UPD)"); } Country ctryo = new Country() { ISO = ctry.ISO, Ctry = ctry.Ctry, IsEU = ctry.IsEU }; bool UpdOk = _clientService.Upd(ctryo); return(ApiControllerHelper.SendOk(this, new ApiResult <bool>(HttpStatusCode.OK, null, UpdOk), true)); } catch (Exception ex) { return(ApiControllerHelper.SendError(this, ex)); } }
public async Task <IActionResult> Get(long id) { var country = await _countryRepository.Query().FirstOrDefaultAsync(x => x.Id == id); if (country == null) { return(NotFound()); } var model = new CountryForm { Id = country.Id, Name = country.Name, Code2 = country.Code2, Code3 = country.Code3, IsBillingEnabled = country.IsBillingEnabled, IsShippingEnabled = country.IsShippingEnabled, }; return(Json(model)); }
private void CountryForm_FormClosing(object sender, FormClosingEventArgs e) { CountryForm = null; }
public IActionResult Create() { var model = new CountryForm(); return(View(model)); }
private void добавить—трануToolStripMenuItem_Click(object sender, EventArgs e) { CountryForm countryForm = new CountryForm(); countryForm.ShowDialog(); }