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));
        }
예제 #2
0
        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());
        }
예제 #4
0
        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();
        }
예제 #5
0
        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" }));
        }
예제 #7
0
        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));
        }
예제 #8
0
 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"));
 }
예제 #9
0
        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);
        }
예제 #10
0
        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);
        }
예제 #11
0
        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"));
        }
예제 #12
0
        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);
        }
예제 #13
0
        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();
        }
예제 #14
0
        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"));
        }
예제 #15
0
        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));
        }
예제 #17
0
        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));
            }
        }
예제 #18
0
 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));
 }
예제 #19
0
        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));
 }
예제 #22
0
 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));
 }
예제 #23
0
 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());
            }
        }
예제 #27
0
        public CountryEditViewModel EditCountry(CountryEditViewModel CountryEditView)
        {
            var Country = CountryService.Update(CountryEditView);

            return(Country);
        }
예제 #28
0
        public CountryEditViewModel AddCountry(CountryEditViewModel CountryEditView)
        {
            var Country = CountryService.Add(CountryEditView);

            return(Country);
        }
예제 #29
0
 public void Remove(CountryEditViewModel Country)
 {
     CountryRepo.Remove(Country.toModel());
     unitOfWork.commit();
 }
예제 #30
0
 public CountryEditControl(CountryEditViewModel viewModel)
 {
     InitializeComponent();
     this.DataContext = viewModel;
 }