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)); }
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)); }