コード例 #1
0
        public ActionResult SaveReferralSocialGroup(ReferralSocialGroup referralSocialGroup)
        {
            try
            {
                using (var db = new StoreContext())
                {
                    int?cnt = db.ReferralSocialGroups.Where(p => p.ReferralSocialGroupId == referralSocialGroup.ReferralSocialGroupId).Count();

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

                    db.SaveChanges();
                    return(Json("1", JsonRequestBehavior.AllowGet));
                }
            }
            catch (Exception ex)
            {
                return(Json(ex.Message, JsonRequestBehavior.AllowGet));
            }
        }
コード例 #2
0
 public ActionResult UpdateReferralSocialGroup(int?id)
 {
     try
     {
         using (var db = new StoreContext())
         {
             this.OrganizeViewBugs(db);
             ReferralSocialGroup item = db.ReferralSocialGroups.Find(id);
             return(View("ReferralSocialGroupTemplate", item));
         }
     }
     catch (Exception ex)
     {
         return(HttpNotFound(ex.Message));
     }
 }
コード例 #3
0
 public ActionResult CreateReferralSocialGroup(int?id)
 {
     try
     {
         using (var db = new StoreContext())
         {
             this.OrganizeViewBugs(db);
             var item = new ReferralSocialGroup();
             item.ReferralId = id;
             return(View("ReferralSocialGroupTemplate", item));
         }
     }
     catch (Exception ex)
     {
         return(HttpNotFound(ex.Message));
     }
 }
コード例 #4
0
 public ActionResult DeleteReferralSocialGroup([DataSourceRequest] DataSourceRequest request, int?id)
 {
     try
     {
         if (ModelState.IsValid)
         {
             using (var db = new StoreContext())
             {
                 var item = new ReferralSocialGroup()
                 {
                     ReferralSocialGroupId = Convert.ToInt32(id),
                 };
                 db.ReferralSocialGroups.Attach(item);
                 db.ReferralSocialGroups.Remove(item);
                 db.SaveChanges();
             }
         }
         return(Json("1", JsonRequestBehavior.AllowGet));
     }
     catch (Exception ex)
     {
         return(Json(ex.Message, JsonRequestBehavior.AllowGet));
     }
 }