예제 #1
0
 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);
 }
예제 #2
0
        public IActionResult AddCountry(CountryViewModel countryVm)
        {
            if (!this.ModelState.IsValid)
            {
                return(this.View(countryVm));
            }

            this.adminService.AddCountryToDb(countryVm);

            return(this.RedirectToAction("Index", "Home"));
        }
예제 #3
0
 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();
 }
예제 #4
0
        public ActionResult Create(CountryViewModel country)
        {
            if (ModelState.IsValid)
            {
                var entity = Mapper.Map <Country>(country);
                countryService.Insert(entity);
                return(RedirectToAction("Index"));
            }

            return(View(country));
        }
예제 #5
0
        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));
        }
예제 #6
0
        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()));
        }
예제 #7
0
        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));
        }
예제 #8
0
        public async Task <ActionResult> Update(Guid id, CountryViewModel countryViewModel)
        {
            if (!ModelState.IsValid)
            {
                return(OkResult(ModelState));
            }

            await _applicationServiceCountry.UpdateAsync(countryViewModel);

            return(OkResult());
        }
예제 #9
0
        public IActionResult Put([FromBody] CountryViewModel ViewModel)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ViewModel));
            }

            _appService.Update(ViewModel);

            return(Ok(ViewModel));
        }
예제 #10
0
        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));
        }
예제 #11
0
        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));
        }
예제 #12
0
        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));
        }
예제 #13
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));
        }
예제 #14
0
        public static CountryViewModel ConvertToViewModel(Country dbModel)
        {
            var viewModel = new CountryViewModel
            {
                Id             = dbModel.Id,
                ISOCountryCode = dbModel.ISOCountryCode,
                Name           = dbModel.Name,
                Enabled        = dbModel.Enabled,
            };

            return(viewModel);
        }
예제 #15
0
 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')"));
     }
 }
예제 #16
0
        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));
        }
예제 #17
0
 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}" }));
     }
 }
예제 #18
0
        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));
        }
예제 #19
0
        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));
        }
예제 #20
0
 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);
     }
 }
예제 #21
0
        public void Update(CountryViewModel CountryVM)
        {
            var Country = new Country
            {
                Id   = CountryVM.Id,
                Name = CountryVM.Name
            };

            unitOfWork.CountryRepository.Update(Country);

            unitOfWork.Save();
        }
예제 #22
0
        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);
        }
예제 #23
0
 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);
        }
예제 #25
0
 public bool IsCountryExists(CountryViewModel Country)
 {
     try
     {
         bool IsOrder = _repository.CountryRepository.Any(cc => cc.ID == Country.ID);
         return(IsOrder);
     }
     catch (Exception)
     {
         return(false);
     }
 }
예제 #26
0
        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);
        }
예제 #27
0
        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);
        }
예제 #28
0
 public async Task Create(CountryViewModel ABC)
 {
     try
     {
         this.BusinessLayer.Create(ABC);
     }
     catch (Exception ex)
     {
         this.ExceptionLogger.Log(LogLevel.Error, ex);
         throw ex;
     }
 }
예제 #29
0
 public ActionResult AddCountry()
 {
     try
     {
         CountryViewModel model = new CountryViewModel();
         return(View(model));
     }
     catch (Exception ex)
     {
         return(View());
     }
 }
예제 #30
0
        public ActionResult Edit(CountryViewModel model)
        {
            CountryDTO country = new CountryDTO
            {
                Id   = model.Id,
                Name = model.Name.Trim()
            };

            countryService.Update(country);

            return(RedirectToAction("Index"));
        }
예제 #31
0
        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));
        }
예제 #32
0
        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);
        }
예제 #33
0
        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));
        }
예제 #34
0
        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;
        }
예제 #35
0
        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);
        }
예제 #36
0
        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));
        }
예제 #37
0
 public ActionResult CreateCountry()
 {
     CountryViewModel vmCountry = new CountryViewModel();
     return View(vmCountry);
 }
예제 #38
0
        public ActionResult CountriesDestroy([DataSourceRequest]DataSourceRequest request, CountryViewModel country)
        {
            this.countries.Delete(country.Id);

            return this.Json(new[] { country }.ToDataSourceResult(request, this.ModelState));
        }
예제 #39
0
        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);
        }
예제 #40
0
 public ActionResult UpdateCountry(int id)
 {
     CountryViewModel vmCountry = new CountryViewModel();
     vmCountry.Read(id);
     return View(vmCountry);
 }
예제 #41
0
    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);
        }
    }