Exemplo n.º 1
0
        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());
        }
Exemplo n.º 2
0
 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"));
     }
 }
Exemplo n.º 3
0
        private void barButtonCountry_ItemClick(object sender, ItemClickEventArgs e)
        {
            CountryForm xform1 = new CountryForm(_FlexSys)
            {
                MdiParent = this
            };

            xform1.Show();
        }
Exemplo n.º 4
0
 private void mnuManageExit_Click(object sender, EventArgs e)
 {
     this.Hide();
     UserForm    = null;
     AddressForm = null;
     CountryForm = null;
     StateForm   = null;
     reLogin.Call();
     this.Close();
 }
Exemplo n.º 5
0
 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));
 }
Exemplo n.º 6
0
 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();
     }
 }
Exemplo n.º 7
0
        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));
        }
Exemplo n.º 9
0
        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));
        }
Exemplo n.º 10
0
 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));
     }
 }
Exemplo n.º 11
0
        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));
        }
Exemplo n.º 12
0
 private void CountryForm_FormClosing(object sender, FormClosingEventArgs e)
 {
     CountryForm = null;
 }
Exemplo n.º 13
0
        public IActionResult Create()
        {
            var model = new CountryForm();

            return(View(model));
        }
Exemplo n.º 14
0
        private void добавить—трануToolStripMenuItem_Click(object sender, EventArgs e)
        {
            CountryForm countryForm = new CountryForm();

            countryForm.ShowDialog();
        }