public ActionResult Edit(CountryViewModel model) { if (ModelState.IsValid) { var country = countryService.AddOrUpdate(model); return RedirectToAction("Index") .WithSuccess(string.Format("Details for country \"{0}\" have been updated".TA(), country.Name)); } return View(model); }
public IActionResult AddCountry(CountryViewModel countryVm) { if (!this.ModelState.IsValid) { return(this.View(countryVm)); } this.adminService.AddCountryToDb(countryVm); return(this.RedirectToAction("Index", "Home")); }
public ActionResult AddCountry(CountryViewModel model) { if (this.ModelState.IsValid) { Mapper.CreateMap<CountryViewModel, CountryDto>(); var country = Mapper.Map<CountryDto>(model); this.countryService.CreateCountry(country); this.countryService.Commit(); } return this.View(); }
public ActionResult Create(CountryViewModel country) { if (ModelState.IsValid) { var entity = Mapper.Map <Country>(country); countryService.Insert(entity); return(RedirectToAction("Index")); } return(View(country)); }
public async Task <IActionResult> Create([Bind("Name")] CountryViewModel country) { if (ModelState.IsValid) { var returnCountry = await _service.CreateAsync(country.MapCountryViewToDTO()); country = returnCountry.MapCountryDTOToView(); return(RedirectToAction(nameof(Index))); } return(View(country)); }
public ActionResult AddCountry(CountryViewModel countryModel) { if (this.ModelState.IsValid) { var mappedCountry = MappingService.MappingProvider.Map <Country>(countryModel); this.countryService.Add(mappedCountry); } this.TempData[GlobalConstants.SuccessMessage] = string.Format("Country {0} added successfully!", countryModel.Name); return(this.RedirectToAction <CountriesGridController>(c => c.Index())); }
public ActionResult Edit(Guid?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Country country = _service.GetCountryById(id); CountryViewModel viewModelList = Mapper.Map <Country, CountryViewModel>(country); return(View(viewModelList)); }
public async Task <ActionResult> Update(Guid id, CountryViewModel countryViewModel) { if (!ModelState.IsValid) { return(OkResult(ModelState)); } await _applicationServiceCountry.UpdateAsync(countryViewModel); return(OkResult()); }
public IActionResult Put([FromBody] CountryViewModel ViewModel) { if (!ModelState.IsValid) { return(BadRequest(ViewModel)); } _appService.Update(ViewModel); return(Ok(ViewModel)); }
public IActionResult Index(CountryViewModel model) { //if (ModelState.IsValid) //{ // var msg = model.Country + " selected"; // return RedirectToAction("IndexSuccess", new { message = msg }); //} // If we got this far, something failed; redisplay form. return(View(model)); }
public ViewResult Details(string id) { var session = new CountrySession(HttpContext.Session); var model = new CountryViewModel { Country = context.Countries.Include(t => t.GameType).Include(t => t.Category).FirstOrDefault(t => t.CountryId == id), ActiveGame = session.GetActiveGame(), ActiveCat = session.GetActiveCat() }; return(View(model)); }
public IActionResult Index(CountryViewModel model) { if (ModelState.IsValid) { var msg = model.Country + " selected"; return(RedirectToAction("IndexSuccess", new { message = msg })); } // If we got this far, something failed; redisplay form. return(View("/Views/Country/Index.cshtml", model)); }
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 static CountryViewModel ConvertToViewModel(Country dbModel) { var viewModel = new CountryViewModel { Id = dbModel.Id, ISOCountryCode = dbModel.ISOCountryCode, Name = dbModel.Name, Enabled = dbModel.Enabled, }; return(viewModel); }
public JavaScriptResult Create(CountryViewModel countryvm) { try { _countryService.Add(Mapper.Map <Country>(countryvm)); return(JavaScript($"ShowResult('{"Data saved successfully."}','{"success"}','{"redirect"}','{"."}')")); } catch (Exception ex) { return(JavaScript($"ShowResult('{ex.Message}','failure')")); } }
public ActionResult Create([Bind(Include = "Id,Name,IsDeleted,ModifiedDate,ModifiedUserId,DeletionDate,DeletionUserId")] CountryViewModel countryViewModel) { if (ModelState.IsValid) { countryViewModel.Id = Guid.NewGuid(); country.AddCountry(countryViewModel); //db.CountryViewModels.Add(countryViewModel); return(RedirectToAction("Index")); } return(View(countryViewModel)); }
public HttpResponseMessage UpdateCounty([FromBody] CountryViewModel model) { try { var data = repo.UpdateCountry(model); return(Request.CreateResponse(HttpStatusCode.OK, new { success = true, result = model, message = "The record has successfully been updated" })); } catch (Exception e) { return(Request.CreateResponse(HttpStatusCode.OK, new { success = false, result = model, message = $"There was error updating this record {e.Message}" })); } }
public async Task <IActionResult> UpdateCountry(string code) { NullGuard.NotNullOrWhiteSpace(code, nameof(code)); ICountry country = await GetCountry(code); CountryViewModel countryViewModel = _contactViewModelConverter.Convert <ICountry, CountryViewModel>(country); countryViewModel.EditMode = EditMode.Edit; return(View("UpdateCountry", countryViewModel)); }
public IActionResult IndexEmpty(CountryViewModel model) { if (ModelState.IsValid) { var msg = !System.String.IsNullOrEmpty(model.Country) ? model.Country : "No selection"; msg += " Selected"; return(RedirectToAction("IndexSuccess", new { message = msg })); } return(View(model)); }
public bool IsNameCountryAvailble(string Name, CountryViewModel Country) { try { bool IsOrder = !_repository.CountryRepository.Any(cc => cc.Name.Trim().ToLower() == Name.Trim().ToLower() && cc.ID != Country.ID); return(IsOrder); } catch (Exception) { return(true); } }
public void Update(CountryViewModel CountryVM) { var Country = new Country { Id = CountryVM.Id, Name = CountryVM.Name }; unitOfWork.CountryRepository.Update(Country); unitOfWork.Save(); }
public void LoadCountriesMethod_ShouldMakeCountries_WhenCalled() { CountryViewModel cvm = new CountryViewModel(); ObservableCollection <ICountry> collection = new ObservableCollection <ICountry>(); ObservableCollection <ICountry> collectionAfterLoad = new ObservableCollection <ICountry>(); collectionAfterLoad = cvm.Countries; cvm.LoadCountries(); Assert.AreNotEqual(collection, collectionAfterLoad); }
private Country MapViewModelToCountry(CountryViewModel countryViewModel, int capitalId, int regionId) { return(new Country() { Name = countryViewModel.Name, NumericCode = countryViewModel.NumericCode, CapitalId = capitalId, Area = float.Parse(countryViewModel.Area, CultureInfo.InvariantCulture), Population = countryViewModel.Population, RegionId = regionId }); }
public CountryViewModel GetCountry(int id) { CountryViewModel CountryViewModel = new CountryViewModel(); NGOdata.Country GetCountry; GetCountry = db.Country.Where(x => x.Id == id).FirstOrDefault(); Mapper.CreateMap <Country, CountryViewModel>(); CountryViewModel = Mapper.Map <Country, CountryViewModel>(GetCountry); return(CountryViewModel); }
public bool IsCountryExists(CountryViewModel Country) { try { bool IsOrder = _repository.CountryRepository.Any(cc => cc.ID == Country.ID); return(IsOrder); } catch (Exception) { return(false); } }
public CountryViewModel GetCountry(int id) { var country = _locationRespository.GetCountry(id); var countryVM = new CountryViewModel() { Id = country.Id, Name = country.Name, Code = country.Code }; return(countryVM); }
public IActionResult Edit(int id) { var country = countryService.Get(id); var countryViewModel = new CountryViewModel { Id = id, Name = country.Name, Code = country.Code }; return View(countryViewModel); }
public async Task Create(CountryViewModel ABC) { try { this.BusinessLayer.Create(ABC); } catch (Exception ex) { this.ExceptionLogger.Log(LogLevel.Error, ex); throw ex; } }
public ActionResult AddCountry() { try { CountryViewModel model = new CountryViewModel(); return(View(model)); } catch (Exception ex) { return(View()); } }
public ActionResult Edit(CountryViewModel model) { CountryDTO country = new CountryDTO { Id = model.Id, Name = model.Name.Trim() }; countryService.Update(country); return(RedirectToAction("Index")); }
public IActionResult Create(CountryViewModel model) { // if (ModelState.IsValid) // { // var msg = model.Country + " selected"; // return RedirectToAction("Success", new { message = msg }); // } // If we got this far, something failed; redisplay form. Console.WriteLine(System.DateTime.Now); return(Ok(model)); }
public static CountryViewModel Convert(Country country) { var countryViewModel = new CountryViewModel(); countryViewModel.Id = country.Id; countryViewModel.Name = country.Name; countryViewModel.Alpha2 = country.Alpha2; countryViewModel.Alpha3 = country.Alpha3; countryViewModel.Iso = country.Iso; return(countryViewModel); }
public ActionResult CountriesUpdate([DataSourceRequest]DataSourceRequest request, CountryViewModel country) { var countryExists = this.countries.All().Any(m => m.Name == country.Name); if (countryExists) { this.ModelState.AddModelError("Major exists", "Major will such name already exists."); } if (this.ModelState.IsValid) { var entity = this.Mapper.Map<Country>(country); this.countries.Update(entity); } return this.Json(new[] { country }.ToDataSourceResult(request, this.ModelState)); }
public Country AddOrUpdate(CountryViewModel model) { Country country = null; var dbCountry = Find(model.Code); if (dbCountry == null) { country = Mapper.Map<Country>(model); db.Countries.Add(country); } else { Mapper.Map(model, dbCountry); } db.SaveChanges(); return dbCountry ?? country; }
public ActionResult CreateCountry(CountryViewModel model, HttpPostedFileBase uploadIcon, HttpPostedFileBase uploadImage) { try { model.Icon = savefile(uploadIcon, model.Name + "_icon"); model.Image = savefile(uploadImage, model.Name + "_image"); int id = model.Create(); if (id > 0) { return RedirectToAction("countries"); } } catch (Exception) { } return View(model); }
public ActionResult CountriesCreate([DataSourceRequest]DataSourceRequest request, CountryViewModel country) { var countryExists = this.countries.All().Any(m => m.Name == country.Name); if (countryExists) { this.ModelState.AddModelError("Major exists", "Major with such name already exists."); } Country result = null; if (this.ModelState.IsValid) { result = this.countries.Create(country.Name); } if (result != null) { return this.Json(new[] { result }.ToDataSourceResult(request, this.ModelState)); } return this.Json(new[] { country }.ToDataSourceResult(request, this.ModelState)); }
public ActionResult CreateCountry() { CountryViewModel vmCountry = new CountryViewModel(); return View(vmCountry); }
public ActionResult CountriesDestroy([DataSourceRequest]DataSourceRequest request, CountryViewModel country) { this.countries.Delete(country.Id); return this.Json(new[] { country }.ToDataSourceResult(request, this.ModelState)); }
public ActionResult UpdateCountry(HttpPostedFileBase uploadIcon, HttpPostedFileBase uploadImage, CountryViewModel model) { try { if (uploadImage != null) { model.Image = savefile(uploadImage, model.Name + "_image"); } if (uploadIcon != null) { model.Icon = savefile(uploadIcon, model.Name + "_icon"); } bool result = model.Update(); if (result) { return RedirectToAction("countries"); } } catch (Exception) { } return View(model); }
public ActionResult UpdateCountry(int id) { CountryViewModel vmCountry = new CountryViewModel(); vmCountry.Read(id); return View(vmCountry); }
public void Read() { // TO DO : Read ALL List<MYFAN.BusinessObjects.Country> categories = (new MYFAN.BusinessLogic.Country()).ReadAll(); foreach (var item in categories) { CountryViewModel vm = new CountryViewModel(); vm.MapFrom(item); _CountryList.Add(vm); } }