public IActionResult Edit(string languagename, string countryname, int languageid, int clang) { CountryEditViewModel ced = null; if (languagename == "English") { var clList = GetCountryLanguageList().Where(l => l.LanguageID == languageid && l.CountryName == countryname).ToList()[0]; ced = new CountryEditViewModel() { Country = clList.CountryName, Language = clList.LanguageName, CountryLanguageID = clList.CountryLanguageID, CountryID = clList.CountryID, CountryLanguage = clList.CountryLanguageName }; } else { var clList = GetCountryLanguageList().Where(l => l.CountryLanguageID == clang).ToList()[0]; ced = new CountryEditViewModel() { Country = clList.CountryLanguageName, Language = clList.LanguageName, CountryLanguageID = clList.CountryLanguageID, CountryID = clList.CountryID, }; } return(View(ced)); }
public CountryEditViewModel Update(CountryEditViewModel country) { Country _country = CountryRepo.Update(country.toModel()); unitOfWork.commit(); return(_country.toEditViewModel()); }
public IActionResult Edit(CountryEditViewModel cem) { if (cem is null) { throw new System.ArgumentNullException(nameof(cem)); } int i; if (ModelState.IsValid) { if (cem.Language == "English") { Countries co = new Countries(); co.Name = cem.Country; co.CountryId = cem.CountryID; i = _countryrepo.Update(co); } else { CountryLanguages cl = new CountryLanguages() { CountryLanguageId = cem.CountryLanguageID, Name = cem.Country, CountryId = cem.CountryID, LanguageId = cem.LanguageId }; i = _countrylang.Update(cl); } if (i > 0) { return(RedirectToAction("Index")); } } return(View()); }
private void EditCountry(string countryName) { CountryEditViewModel viewModel = new CountryEditViewModel(countryName); CountryEditControl control = new CountryEditControl(viewModel); Window window = WindowFactory.CreateByContentsSize(control); viewModel.CountryEdited += (s, e) => { CountryEditModel countryEditModel = e.Country; CountryEditDTO countryEditDTO = Mapper.Map <CountryEditModel, CountryEditDTO>(countryEditModel); using (ICountryService service = factory.CreateCountryService()) { ServiceMessage serviceMessage = service.Update(countryEditDTO); RaiseReceivedMessageEvent(serviceMessage.IsSuccessful, serviceMessage.Message); if (serviceMessage.IsSuccessful) { window.Close(); Notify(); } } }; window.Show(); }
public ActionResult Edit(CountryEditViewModel model) { Country country = _context.Countries.FirstOrDefault(c => c.Id == model.Id); country.Name = model.Name; country.Priority = model.Priority; _context.SaveChanges(); return(RedirectToAction("Index")); }
public async Task <IActionResult> Edit(CountryEditViewModel countryEditViewModel) { if (!this.ModelState.IsValid) { return(this.View(countryEditViewModel)); } await this.countriesService.EditAsync(countryEditViewModel); return(this.RedirectToAction("GetAll", "Countries", new { area = "Administration" })); }
public ActionResult Edit(int id) { Country country = _context.Countries.FirstOrDefault(c => c.Id == id); CountryEditViewModel model = new CountryEditViewModel { Name = country.Name, Priority = country.Priority }; return(View(model)); }
public ActionResult Edit(CountryEditViewModel model, int id) { if (!ModelState.IsValid) { ModelState.AddModelError("", "Are you retarded or something?"); return(View(model)); } _context.Countries.FirstOrDefault(c => c.Id == id).Name = model.Name; _context.Countries.FirstOrDefault(c => c.Id == id).Priority = model.Priority; _context.SaveChanges(); return(RedirectToAction("Index")); }
public async Task CheckIfEditingCountryWorksCorrectly() { this.SeedDatabase(); var countryEditViewModel = new CountryEditViewModel { Id = this.firstCountry.Id, Name = "Changed Country name", }; await this.countriesService.EditAsync(countryEditViewModel); Assert.Equal(countryEditViewModel.Name, this.firstCountry.Name); }
public async Task CheckIfEditingCountryReturnsNullReferenceException() { this.SeedDatabase(); var countryEditViewModel = new CountryEditViewModel { Id = 3, }; var exception = await Assert .ThrowsAsync <NullReferenceException>(async() => await this.countriesService.EditAsync(countryEditViewModel)); Assert.Equal(string.Format(ExceptionMessages.CountryNotFound, countryEditViewModel.Id), exception.Message); }
public ActionResult Edit(int id) { var country = _context.Countries.SingleOrDefault(x => x.Id == id); if (country != null) { CountryEditViewModel model = new CountryEditViewModel(); model.Id = id; model.Name = country.Name; model.Priority = country.Priority; return(View(model)); } return(RedirectToAction("Edit")); }
public bool Update(CountryEditViewModel countryVM) { var country = countryRep.GetByName(countryVM.Name); if (country != null && country.Id != countryVM.Id) { return(false); } var update = countryRep.GetById(countryVM.Id); update.Name = countryVM.Name; countryRep.SaveChanges(); return(true); }
public async Task EditAsync(CountryEditViewModel countryEditViewModel) { var country = this.countriesRepository.All().FirstOrDefault(g => g.Id == countryEditViewModel.Id); if (country == null) { throw new NullReferenceException( string.Format(ExceptionMessages.CountryNotFound, countryEditViewModel.Id)); } country.Name = countryEditViewModel.Name; country.ModifiedOn = DateTime.UtcNow; this.countriesRepository.Update(country); await this.countriesRepository.SaveChangesAsync(); }
public ActionResult Edit(int id) { var country = _context.Countries.FirstOrDefault(c => c.Id == id); if (country != null) { var model = new CountryEditViewModel { Id = country.Id, Name = country.Name, Priority = country.Priority }; return(View(model)); } return(RedirectToAction("Index")); }
public CountryEditViewModel GetCountryEditById(int id) { CountryEditViewModel model = null; var country = _countryRepository.GetCountryById(id); if (country != null) { model = new CountryEditViewModel { Id = country.Id, Name = country.Name, Priority = country.Priority }; } return(model); }
public IActionResult Edit(int id) { var objcountry = _CountryRegistrationservices.GetById(id); if (objcountry == null) { return(NotFound()); } var model = new CountryEditViewModel { id = objcountry.id, countryname = objcountry.countryname, }; return(View(model)); }
public ActionResult CountryEdit(string id, CountryEditViewModel model) { if (ModelState.IsValid) { //-- Need to invalidate the cache... what about other app domains like the rss one? SHIT! var country = AppLookups.Countries.Where(c => c.NameUrlPart == id).SingleOrDefault(); country.GeoReduceThreshold = model.GeoReduceThreshold; country.Geo = SqlGeography.Parse(new SqlString(model.WKT)); geoSvc.UpdateCountry(country); return(RedirectToAction("CountryEdit")); } else { return(RedirectToAction("CountryEdit", model)); } }
public ActionResult Edit(CountryEditViewModel model) { if (ModelState.IsValid) { Country searchCountry = _context.Countries.SingleOrDefault(x => x.Id == model.Id); if (searchCountry != null) { //old.DateCreate = DateTime.Now; searchCountry.Name = model.Name; searchCountry.Priority = model.Priority; _context.SaveChanges(); } return(RedirectToAction("Index")); } ModelState.AddModelError("", "І тут затупив:-)))"); return(View(model)); }
public ActionResult Edit(CountryEditViewModel countryVM) { if (ModelState.IsValid) { bool editConfirtm = countryService.Update(countryVM); if (!editConfirtm) { ModelState.AddModelError("Name", "Name already exists"); return(View(countryVM)); } return(RedirectToAction("Index")); } return(View()); }
public IActionResult Edit(string id) { var existsCountry = this.countriesService .Exists(x => x.Id == id); if (!existsCountry) { return(this.NotFound()); } var country = new CountryEditViewModel() { Id = id, CountryInput = this.countriesService .GetSingle <CountryInputModel>(x => x.Id == id), }; return(this.View(country)); }
public ActionResult Edit(CountryEditViewModel countryModel) { if (ModelState.IsValid) { var operationStatus = _locationService.CountryEdit(countryModel); if (operationStatus == CountryStatusViewModel.Success) { return(RedirectToAction("Index")); } else if (operationStatus == CountryStatusViewModel.Dublication) { ModelState.AddModelError("", "Країна з даним іменем вже існує"); } else if (operationStatus == CountryStatusViewModel.Error) { ModelState.AddModelError("", "Помилка редагування"); } } return(View(countryModel)); }
public ActionResult Edit(CountryEditViewModel country) { if (ModelState.IsValid) { var status = _locationProvider.CountryEdit(country); if (status == StatusCountryViewModel.Success) { return(RedirectToAction("Index")); } else if (status == StatusCountryViewModel.Dublication) { ModelState.AddModelError("", "Країна за даним іменем уже існує!"); } else if (status == StatusCountryViewModel.Error) { ModelState.AddModelError("", "Помилка редагування"); } } return(View(country)); }
public CountryStatusViewModel CountryEdit(CountryEditViewModel editCountry) { try { var searchCountry = _countryRepository.GetCountryByName(editCountry.Name); if (searchCountry != null && searchCountry.Id != editCountry.Id) { return(CountryStatusViewModel.Dublication); } var country = _countryRepository.GetCountryById(editCountry.Id); if (country != null) { country.Name = editCountry.Name; country.Priority = editCountry.Priority; _countryRepository.SaveChange(); return(CountryStatusViewModel.Success); } } catch { } return(CountryStatusViewModel.Error); }
public async Task <IActionResult> Edit(string id, CountryInputModel countryInput) { var existsId = this.countriesService .Exists(x => x.Id == id); if (!existsId) { return(this.NotFound()); } var existsCountry = this.countriesService .Exists(x => x.Id != id && (x.Name == countryInput.Name || x.CountryCode == countryInput.CountryCode)); if (!this.ModelState.IsValid || existsCountry) { if (existsCountry) { this.ModelState.AddModelError(MatchingCountryKey, MatchingCountryErrorMessage); } var country = new CountryEditViewModel() { Id = id, CountryInput = countryInput, }; return(this.View(country)); } var image = await this.cloudinaryService.SaveImageAsync(countryInput.FormFile); await this.countriesService.EditAsync(id, countryInput, image); var countryNameEncoded = HttpUtility.HtmlEncode(countryInput.Name); this.TempData[GlobalConstants.MessageKey] = $"Successfully edited country <strong>{countryNameEncoded}</strong>!"; return(this.RedirectToAction("Details", "Countries", new { area = "Places", id })); }
public async Task <IActionResult> PutCountries([FromRoute] long id, [FromBody] CountryEditViewModel model) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } Country country = new Country { Id = id, Name = model.Name }; _context.Entry(country).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CountryExists(id)) { return(NotFound()); } else { throw; } } var obj = new SelectViewModel { Value = country.Id, Label = country.Name }; return(Ok(obj)); }
public async Task <IActionResult> Edit(CountryEditViewModel model) { if (ModelState.IsValid) { var objcountry = _CountryRegistrationservices.GetById(model.id); if (objcountry == null) { return(NotFound()); } objcountry.id = model.id; objcountry.countryname = model.countryname; await _CountryRegistrationservices.UpdateAsync(objcountry); TempData["success"] = "Record Updated successfully"; return(RedirectToAction(nameof(Index))); } else { return(View()); } }
public CountryEditViewModel EditCountry(CountryEditViewModel CountryEditView) { var Country = CountryService.Update(CountryEditView); return(Country); }
public CountryEditViewModel AddCountry(CountryEditViewModel CountryEditView) { var Country = CountryService.Add(CountryEditView); return(Country); }
public void Remove(CountryEditViewModel Country) { CountryRepo.Remove(Country.toModel()); unitOfWork.commit(); }
public CountryEditControl(CountryEditViewModel viewModel) { InitializeComponent(); this.DataContext = viewModel; }