Ejemplo n.º 1
0
        private CountryDTO Create(CountryViewModel viewModel)
        {
            try
            {
                log.Debug(CountryViewModel.FormatCountryViewModel(viewModel));

                CountryDTO country = new CountryDTO();

                // copy values
                viewModel.UpdateDTO(country, null); //RequestContext.Principal.Identity.GetUserId());

                // audit
                country.CreateBy = null; //RequestContext.Principal.Identity.GetUserId();
                country.CreateOn = DateTime.UtcNow;

                // add
                log.Debug("_countryService.AddCountry - " + CountryDTO.FormatCountryDTO(country));

                int id = _countryService.AddCountry(country);

                country.CountryId = id;

                log.Debug("result: 'success', id: " + id);

                return(country);
            }
            catch (Exception e)
            {
                // error
                log.Error(e.ToString());

                throw;
            }
        }
        public void Setup()
        {
            //add currency
            var britishCurrency = new Entities.Currencies.Currency
            {
                Name   = "British Pound",
                Code   = "GBP",
                Format = "£0.00"
            };

            _currencyService.Add(britishCurrency);

            var taxRate = new TaxRate
            {
                Name       = "VAT",
                Code       = "S",
                Percentage = 20m
            };

            _taxRateManager.Add(taxRate);

            var uk = new Country
            {
                Name             = "United Kingdom",
                ISOTwoLetterCode = "GB"
            };

            _countryService.AddCountry(uk);
        }
Ejemplo n.º 3
0
 public ActionResult CreateEdit(UCountry country)
 {
     if (ModelState.IsValid)
     {
         if (!country._country.Id.Equals(Guid.Empty))
         {
             if (countryService.EditCountry(country._country))
             {
                 ModelState.Clear();
                 country         = new UCountry();
                 ViewBag.Message = Resources.CountryController_String_CountryUpdated;
             }
             else
             {
                 ViewBag.Error = Resources.CountryController_String_CountryNotSaved;
             }
         }
         else
         {
             if (countryService.AddCountry(country._country))
             {
                 ModelState.Clear();
                 country         = new UCountry();
                 ViewBag.Message = Resources.CountryController_String_CountryAdded;
             }
             else
             {
                 ViewBag.Error = Resources.CountryController_String_CountryNotSaved;
             }
         }
     }
     country.CurrencySelect = new SelectList(countryService.CurrencyObj.GetCurrencies(countryProg.Id), "Id", "Name");
     return(ListView());
 }
        public async Task <IActionResult> Create([FromBody] AddCountryInputDto addinput)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }
            var result = await CountryService.AddCountry(addinput);

            return(Ok(result));
        }
Ejemplo n.º 5
0
        public IHttpActionResult PostCountry(CountryDTO countryDto)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            var newCountry = countryService.AddCountry(countryDto);

            return(CreatedAtRoute("DefaultApi", new { id = newCountry.ID }, newCountry));
        }
Ejemplo n.º 6
0
        public void CountryController_AddPost_CallsAddCountryWithPassedValue()
        {
            var country = new Country()
            {
                Name = "Great Britain", ISOTwoLetterCode = "GB"
            };

            _countryController.Add_POST(country);

            A.CallTo(() => _countryService.AddCountry(country)).MustHaveHappened();
        }
Ejemplo n.º 7
0
        public ActionResult Create([Bind(Include = "Id,Title")] CountryViewModel countryViewModel)
        {
            if (ModelState.IsValid)
            {
                countryViewModel.Id = Guid.NewGuid();
                Country country = Mapper.Map <CountryViewModel, Country>(countryViewModel);
                _service.AddCountry(country);
                return(RedirectToAction("Index"));
            }

            return(View(countryViewModel));
        }
        public async Task <IActionResult> AddSubscription(CountryDto countryDto)
        {
            try
            {
                var country = _mapper.Map <Country>(countryDto);
                _countryService.AddCountry(country);
                await _unitOfWork.Save();

                return(Ok(country));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }
Ejemplo n.º 9
0
        public JsonResult AddCountry(CountryModel model)
        {
            bool flag = false;

            try
            {
                model.CountryId = Guid.NewGuid();
                _countryService.AddCountry(model);
                flag = true;
            }
            catch (Exception ex)
            {
                flag = false;
            }
            return(Json(flag));
        }
Ejemplo n.º 10
0
        public async Task <IActionResult> OnPost()
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(Page());
                }
                await countryService.AddCountry(NewCountry);

                State = true;
                return(RedirectToPage("./Country"));
            }
            catch (Exception e)
            {
                State             = false;
                ViewData["Error"] = e.Message;
                return(Page());
            }
        }
        public async Task <IActionResult> AddCounty(string Country, string IsoCode)
        {
            var contry = await countryService.AddCountry(Guid.NewGuid(), Country, IsoCode);

            return(Ok(contry));
        }
Ejemplo n.º 12
0
 public RedirectToRouteResult Add_POST(Country country)
 {
     _countryService.AddCountry(country);
     return(RedirectToAction("Index"));
 }
Ejemplo n.º 13
0
        public async Task <Unit> Handle(CreateCountryCommand request, CancellationToken cancellationToken)
        {
            await _countryService.AddCountry(request.Country);

            return(Unit.Value);
        }