예제 #1
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IdentityDbContext dbContext)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            // temp: to generate data into the test db
            dbContext.Database.EnsureCreated();

            // forcefully reload the social user and social domain's relationships
            dbContext.Entry(dbContext.Users.Find(SocialDomainAdminId)).Collection(x => x.Domains).Load();
            dbContext.Entry(dbContext.Domains.Find(SocialDomainId)).Collection(x => x.Users).Load();


            app.UseRouting();
            app.UseAuthorization();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapGrpcService <AccountService>();
                endpoints.MapGrpcService <AuthenticationService>();
                endpoints.MapGrpcService <DomainsService>();
                endpoints.MapGrpcService <ProjectsService>();
                endpoints.MapGrpcService <UsersService>();
                endpoints.MapGrpcService <InteropService>();

                endpoints.MapGet("/", async context =>
                {
                    await context.Response.WriteAsync("Communication with gRPC endpoints must be made through a gRPC client. To learn how to create a client, visit: https://go.microsoft.com/fwlink/?linkid=2086909");
                });
            });
        }
예제 #2
0
        public async Task <bool> Add(TEntity entity)
        {
            _context.Entry(entity).State = EntityState.Added;
            int changes = await _context.SaveChangesAsync();

            return(changes > 0);
        }
예제 #3
0
        public bool Add(TEntity entity)
        {
            _context.Entry(entity).State = EntityState.Added;
            int changes = _context.SaveChanges();

            return(changes > 0);
        }
예제 #4
0
        public void Update(TEntity entity)
        {
            var entry = _context.Entry(entity);

            if (entry.State == EntityState.Detached)
            {
                Set.Attach(entity);
                entry = _context.Entry(entity);
            }
            entry.State = EntityState.Modified;
        }
예제 #5
0
        public async Task <IActionResult> DeleteApp(string id)
        {
            _identityContext.Entry(_identityContext.UserApplications.Single(x =>
                                                                            x.AppId == id && x.UserId == User.FindFirstValue(ClaimTypes.NameIdentifier))).State = EntityState.Deleted;

            _identityContext.Entry(_identityContext.Applications.Single(x =>
                                                                        x.Id == id)).State = EntityState.Deleted;

            await _identityContext.SaveChangesAsync();

            return(RedirectToAction("Manage"));
        }
예제 #6
0
        public CommonTest()
        {
            InitializeVariables();
            var options = new DbContextOptionsBuilder <IdentityDbContext>()
                          .UseSqlite("DataSource=:memory:")
                          .Options;

            db = new IdentityDbContext(options);

            FillData(db);

            db.Entry(db.Users.Find(SocialDomainAdminId)).Collection(x => x.Domains).Load();
            db.Entry(db.Domains.Find(SocialDomainId)).Collection(x => x.Users).Load();
        }
예제 #7
0
 public ActionResult Edit(Genre genre)
 {
     if (ModelState.IsValid)
     {
         db.Entry(genre).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(genre));
 }
예제 #8
0
 public void Update(T entity)
 {
     if (entity != null)
     {
         DbSet.Attach(entity);
         Context.Entry(entity).State = EntityState.Modified;
     }
     else
     {
         throw new Exception();
     }
 }
예제 #9
0
        public ActionResult Edit(Microsoft.AspNet.Identity.EntityFramework.IdentityRole role)
        {
            try
            {
                IdentityDbContext context = new IdentityDbContext();
                context.Entry(role).State = System.Data.Entity.EntityState.Modified;
                context.SaveChanges();

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
예제 #10
0
 public void Update(T item)
 {
     try
     {
         if (item == null)
         {
             throw new ArgumentNullException("item");
         }
         _context.Entry(item).State = EntityState.Modified;
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
 public ActionResult Edit(IdentityUser applicationUser, string[] roleId)
 {
     if (ModelState.IsValid)
     {
         db.Entry(applicationUser).State = EntityState.Modified;
         db.SaveChanges();
         var rolesForUser = UserManager.GetRoles(applicationUser.Id);
         foreach (var item in rolesForUser)
         {
             UserManager.RemoveFromRole(applicationUser.Id, item.ToString());
         }
         if (roleId != null)
         {
             foreach (var item in roleId)
             {
                 UserManager.AddToRole(applicationUser.Id, item.ToString());
             }
         }
         return(RedirectToAction("Index"));
     }
     return(View(applicationUser));
 }
예제 #12
0
 public void Update(UserSession session)
 {
     _identityDbContext.Entry(session).State = EntityState.Modified;
 }
 public void Update(OneTimeSecuredOperation operation)
 {
     _identityDbContext.Entry(operation).State = EntityState.Modified;
 }
 public virtual bool Update(T entity)
 {
     db.Set <T>().Attach(entity);
     db.Entry(entity).State = EntityState.Modified;
     return(db.SaveChanges() > 0);
 }
예제 #15
0
 public void Update(TEntity entity)
 {
     Context.Entry(entity).State = EntityState.Modified;
 }
 public void EditUser(User user)
 {
     _identityDbContext.Entry(user).State = EntityState.Modified;
 }
예제 #17
0
 private Domain.Entities.User LoadUser(UserDomainAssignment assignment)
 {
     dbContext.Entry(assignment).Reference(x => x.User).Load();
     return(assignment.User);
 }