示例#1
0
        public ActionResult CoronaTableUpdate(int?id)
        {
            CoronaTable data = null;

            if (id != null)
            {
                DataBaseContext_Corona db_corona = new DataBaseContext_Corona();
                data = db_corona.CoronaTable.Where(x => x.Id == id).FirstOrDefault();
            }
            return(View(data));
        }
示例#2
0
        public ActionResult CoronaTableEdit(CoronaTable data)
        {
            DataBaseContext_Corona db_corona = new DataBaseContext_Corona();
            AdminPageViewModel     model     = new AdminPageViewModel();

            //Summarizing the Total Values
            var totalTest   = Convert.ToInt32(db_corona.CoronaTable.Select(x => x.TotalTest).AsEnumerable().LastOrDefault());
            var totalCase   = Convert.ToInt32(db_corona.CoronaTable.Select(x => x.TotalCase).AsEnumerable().LastOrDefault());
            var totalDeaths = Convert.ToInt32(db_corona.CoronaTable.Select(x => x.TotalDeaths).AsEnumerable().LastOrDefault());
            var totalHealed = Convert.ToInt32(db_corona.CoronaTable.Select(x => x.TotalHealed).AsEnumerable().LastOrDefault());

            totalTest   = totalTest + data.NumOfTest;
            totalCase   = totalCase + data.NumOfCase;
            totalDeaths = totalDeaths + data.NumOfDeaths;
            totalHealed = totalHealed + data.NumOfHealed;

            data.TotalTest   = totalTest;
            data.TotalCase   = totalCase;
            data.TotalDeaths = totalDeaths;
            data.TotalHealed = totalHealed;

            db_corona.CoronaTable.Add(data);

            int result = db_corona.SaveChanges();

            if (result > 0)
            {
                ViewBag.Result = "Veriler Başarıyla Eklenmiştir";
                ViewBag.Status = "success";
            }

            else
            {
                ViewBag.Result = "Verileri Ekleme İşlemi Gerçekleşememiştir!!!";
                ViewBag.Status = "danger";
            }


            return(View());
        }
示例#3
0
        public ActionResult CoronaTableUpdate(CoronaTable model)
        {
            DataBaseContext_Corona db_corona = new DataBaseContext_Corona();
            CoronaTable            data      = db_corona.CoronaTable.Where(x => x.Id == model.Id).FirstOrDefault();

            if (data != null)
            {
                data.TotalTest   = data.TotalTest - data.NumOfTest + model.NumOfTest;
                data.TotalCase   = data.TotalCase - data.NumOfCase + model.NumOfCase;
                data.TotalHealed = data.TotalHealed - data.NumOfHealed + model.NumOfHealed;
                data.TotalDeaths = data.TotalDeaths - data.NumOfDeaths + model.NumOfDeaths;

                data.NumOfTest          = model.NumOfTest;
                data.NumOfCase          = model.NumOfCase;
                data.NumOfDeaths        = model.NumOfDeaths;
                data.NumOfPatients      = model.NumOfPatients;
                data.NumOfIntensiveCare = model.NumOfIntensiveCare;
                data.NumOfHealed        = model.NumOfHealed;

                int result = db_corona.SaveChanges();

                if (result > 0)
                {
                    ViewBag.Result = "Veriler Başarıyla Güncellenmiştir";
                    ViewBag.Status = "success";
                }

                else
                {
                    ViewBag.Result = "Verileri Güncelleme İşlemi Gerçekleşememiştir!!!";
                    ViewBag.Status = "danger";
                }
            }

            return(View());
        }
示例#4
0
        public ActionResult CoronaTableDelete_Post(int?id)
        {
            if (id != null)
            {
                DataBaseContext_Corona db_corona = new DataBaseContext_Corona();
                CoronaTable            data      = db_corona.CoronaTable.Where(x => x.Id == id).FirstOrDefault();

                db_corona.CoronaTable.Remove(data);
                int result = db_corona.SaveChanges();

                if (result > 0)
                {
                    ViewBag.Result = "Veriler Başarıyla Silinmiştir";
                    ViewBag.Status = "success";
                }

                else
                {
                    ViewBag.Result = "Verileri Silme İşlemi Gerçekleşememiştir!!!";
                    ViewBag.Status = "danger";
                }
            }
            return(RedirectToAction("CoronaTableList", "Admin"));
        }