コード例 #1
0
 public ActionResult Register(AgileCrmModel model)
 {
     ModelState.Remove("Id");
     if (ModelState.IsValid)
     {
         using (var ctx = new SynergyDbContext())
         {
             string ApiName = ApiTypes.AgileCrm.ToString();
             var    api     = ctx.Synergy_API.Where(x => x.Api == ApiName).FirstOrDefault();
             Synergy_ApiConfiguration configuration = new Synergy_ApiConfiguration()
             {
                 ApiId    = api.Id,
                 Email    = model.Email,
                 Key      = model.Key,
                 Url      = model.Url,
                 UserId   = Convert.ToInt32(User.Identity.Name),
                 IsActive = true
             };
             ctx.Synergy_ApiConfigurations.Add(configuration);
             ctx.SaveChanges();
         }
         return(RedirectToAction("Index"));
     }
     return(View(model));
 }
コード例 #2
0
        public ActionResult Register(HubSpotModel model)
        {
            ModelState.Remove("Id");
            if (ModelState.IsValid)
            {
                string ApiName = ApiTypes.HubSpot.ToString();
                var    api     = context.Synergy_API.Where(x => x.Api == ApiName).FirstOrDefault();

                Synergy_ApiConfiguration configuration = new Synergy_ApiConfiguration()
                {
                    Key      = model.Key,
                    Secret   = model.Secret,
                    ApiId    = api.Id,
                    UserId   = Convert.ToInt32(User.Identity.Name),
                    IsActive = true
                };
                context.Synergy_ApiConfigurations.Add(configuration);
                context.SaveChanges();
                return(RedirectToAction("Index"));
            }
            return(View(model));
        }
コード例 #3
0
 public ActionResult Delete(int id, FormCollection collection)
 {
     using (var ctx = new SynergyDbContext())
     {
         var configuration = ctx.Synergy_ApiConfigurations.
                             Where(x => x.Id == id && x.IsActive).FirstOrDefault();
         if (configuration != null)
         {
             configuration.IsActive = false;
         }
         ctx.SaveChanges();
     }
     return(RedirectToAction("Index"));
 }
コード例 #4
0
 public ActionResult Update(AgileCrmModel model)
 {
     if (ModelState.IsValid)
     {
         using (var ctx = new SynergyDbContext())
         {
             var configuration = ctx.Synergy_ApiConfigurations.
                                 Where(x => x.Id == model.Id && x.IsActive).FirstOrDefault();
             if (configuration != null)
             {
                 configuration.Key   = model.Key;
                 configuration.Email = model.Email;
                 configuration.Url   = model.Url;
             }
             ctx.SaveChanges();
         }
         return(RedirectToAction("Index"));
     }
     return(View(model));
 }