Пример #1
0
        public async Task <ActionResult> AddNewAPIToUsers(String apiName)
        {
            var           allUsers = db.Users.ToList();
            USER_API_XREF userApi  = new USER_API_XREF();
            var           newAPI   = db.Available_APIs.SingleOrDefault(v => v.API_Name == apiName);
            int           apiID    = newAPI.API_ID;

            foreach (var user in allUsers)
            {
                userApi.API_ID   = apiID;
                userApi.USER_ID  = user.Id;
                userApi.void_ind = "n";
                db.USER_APIs.Add(userApi);
                await db.SaveChangesAsync();
            }
            return(null);
        }
Пример #2
0
        public async Task <ActionResult> AddInitialAPIsAsync(String userId)
        {
            USER_API_XREF userAPI = new USER_API_XREF();

            var AllAPIs = db.Available_APIs.ToList();

            if (AllAPIs != null)
            {
                foreach (var api in AllAPIs)
                {
                    userAPI.API_ID   = api.API_ID;
                    userAPI.USER_ID  = userId;
                    userAPI.void_ind = "n";
                    db.USER_APIs.Add(userAPI);
                    await db.SaveChangesAsync();
                }
            }
            else
            {
                return(new HttpStatusCodeResult(999, "this didn't work as planned"));
            }

            return(RedirectToAction("Index", "Home"));
        }