Пример #1
0
        public async Task <IActionResult> AddContinent(string continentName)
        {
            var continent = new Continent()
            {
                Name = continentName
            };
            var exContinent = await _continentService.GetContinentAsync(continentName);

            if (exContinent != null)
            {
                TempData["Error"] = "مشکلی در درج قاره پیش آمد! قاره از قبل وجود دارد";
                return(RedirectToAction("Index"));
            }

            var isSucceeded = await _continentService.AddContinentAsync(continent);

            if (!isSucceeded)
            {
                TempData["Error"] = "مشکلی در درج قاره پیش آمد! لطفا اطلاعات وارد شده را بررسی کنید";
                return(RedirectToAction("Index"));
            }

            TempData["Success"] = "قاره موردنظر با موفقیت ثبت گردید";
            return(RedirectToAction("Index"));
        }
Пример #2
0
        public async Task <IActionResult> AddCountry(string countryName, string continentName, int infectedNo, int recoveredNo, int deathNo)
        {
            var continent = await _continentService.GetContinentAsync(continentName);

            var country = new Country()
            {
                ContinentId = continent.Id,
                DeathNo     = deathNo,
                InfectedNo  = infectedNo,
                RecoveredNo = recoveredNo,
                RefreshDate = DateTime.Now,
                Name        = countryName
            };

            var exCountry = await _countryService.GetCountryAsync(countryName);

            if (exCountry != null)
            {
                TempData["Error"] = "مشکلی در درج کشور پیش آمد! کشور از قبل وجود دارد";
                return(RedirectToAction("Index"));
            }

            var isSucceeded = await _countryService.AddCountryAsync(country);

            if (!isSucceeded)
            {
                TempData["Error"] = "مشکلی در درج اطلاعات کشور پیش آمد! لطفا اطلاعات وارد شده را بررسی کنید";
                return(RedirectToAction("Index"));
            }

            TempData["Success"] = "اطلاعات کشور موردنظر با موفقیت ثبت گردید";
            return(RedirectToAction("Index"));
        }