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

            return(View(model));
        }
Beispiel #2
0
        public ActionResult Update(InfusionSoftModel 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));
        }
Beispiel #3
0
        public ActionResult Register(InfusionSoftModel model)
        {
            ModelState.Remove("Id");
            if (ModelState.IsValid)
            {
                string ApiName = ApiTypes.Infusion.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));
        }