コード例 #1
0
        public ActionResult Save(TestDetail test)
        {
            bool status = false;

            if (ModelState.IsValid)
            {
                using (CovidDbEntities dc = new CovidDbEntities())
                {
                    if (test.TestDetailsId > 0)
                    {
                        //Edit
                        var v = dc.TestDetails.Where(a => a.TestDetailsId == test.TestDetailsId).FirstOrDefault();
                        if (v != null)
                        {
                            v.TestName     = test.TestName;
                            v.TestDate     = test.TestDate;
                            v.TestResult   = test.TestResult;
                            v.TotalPrice   = test.TotalPrice;
                            v.DoctorRemark = test.DoctorRemark;
                        }
                    }
                    else
                    {
                        //Save
                        dc.TestDetails.Add(test);
                    }
                    dc.SaveChanges();
                    status = true;
                }
            }
            return(new JsonResult {
                Data = new { Status = status }
            });
        }
コード例 #2
0
        public ActionResult DeleteEmployee(int id)
        {
            bool status = false;

            using (CovidDbEntities dc = new CovidDbEntities())
            {
                var v = dc.TestDetails.Where(a => a.TestDetailsId == id).FirstOrDefault();
                if (v != null)
                {
                    dc.TestDetails.Remove(v);
                    dc.SaveChanges();
                    status = true;
                }
            }
            return(new JsonResult {
                Data = new { Status = status }
            });
        }