public ActionResult Update(int id)
        {
            HubSpotModel model = context.Synergy_ApiConfigurations.
                                 Where(x => x.Id == id && x.IsActive).
                                 Select(x => new HubSpotModel()
            {
                Id     = x.Id,
                Key    = x.Key,
                Secret = x.Secret
            }).FirstOrDefault();

            return(View(model));
        }
        public ActionResult Update(HubSpotModel model)
        {
            if (ModelState.IsValid)
            {
                var configuration = context.Synergy_ApiConfigurations.
                                    Where(x => x.Id == model.Id && x.IsActive).FirstOrDefault();
                if (configuration != null)
                {
                    configuration.Key    = model.Key;
                    configuration.Secret = model.Secret;
                }
                context.SaveChanges();

                return(RedirectToAction("Index"));
            }
            return(View(model));
        }
        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));
        }