예제 #1
0
        public ActionResult SaveReferralSocialDisease(ReferralSocialDisease referralSocialDisease)
        {
            try
            {
                using (var db = new StoreContext())
                {
                    int?cnt = db.ReferralSocialDiseases.Where(p => p.ReferralSocialDiseaseId == referralSocialDisease.ReferralSocialDiseaseId).Count();

                    if (cnt == 0)
                    {
                        db.ReferralSocialDiseases.Add(referralSocialDisease);
                    }
                    else
                    {
                        db.ReferralSocialDiseases.Attach(referralSocialDisease);
                        db.Entry(referralSocialDisease).State = EntityState.Modified;
                    }

                    db.SaveChanges();
                    return(Json("1", JsonRequestBehavior.AllowGet));
                }
            }
            catch (Exception ex)
            {
                return(Json(ex.Message, JsonRequestBehavior.AllowGet));
            }
        }
예제 #2
0
 public ActionResult UpdateReferralSocialDisease(int?id)
 {
     try
     {
         using (var db = new StoreContext())
         {
             this.OrganizeViewBugs(db);
             ReferralSocialDisease item = db.ReferralSocialDiseases.Find(id);
             return(View("ReferralSocialDiseaseTemplate", item));
         }
     }
     catch (Exception ex)
     {
         return(HttpNotFound(ex.Message));
     }
 }
예제 #3
0
 public ActionResult CreateReferralSocialDisease(int?id)
 {
     try
     {
         using (var db = new StoreContext())
         {
             this.OrganizeViewBugs(db);
             var item = new ReferralSocialDisease();
             item.ReferralId = id;
             return(View("ReferralSocialDiseaseTemplate", item));
         }
     }
     catch (Exception ex)
     {
         return(HttpNotFound(ex.Message));
     }
 }
예제 #4
0
 public ActionResult DeleteReferralSocialDisease([DataSourceRequest] DataSourceRequest request, int?id)
 {
     try
     {
         if (ModelState.IsValid)
         {
             using (var db = new StoreContext())
             {
                 var item = new ReferralSocialDisease()
                 {
                     ReferralSocialDiseaseId = Convert.ToInt32(id),
                 };
                 db.ReferralSocialDiseases.Attach(item);
                 db.ReferralSocialDiseases.Remove(item);
                 db.SaveChanges();
             }
         }
         return(Json("1", JsonRequestBehavior.AllowGet));
     }
     catch (Exception ex)
     {
         return(Json(ex.Message, JsonRequestBehavior.AllowGet));
     }
 }