示例#1
0
        public bool SaveJwt(string token, Guid uId)
        {
            var claimJwt = new ClaimJwt
            {
                Jwt    = token,
                UserId = uId
            };

            try
            {
                var claimJwtExists = _ctx.ClaimJwts.FirstOrDefault(x => x.UserId == uId);
                if (claimJwtExists == null)
                {
                    _ctx.Add(claimJwt);
                }
                else
                {
                    claimJwtExists.UserId = uId;
                    claimJwtExists.Jwt    = token;

                    _ctx.Entry(claimJwtExists).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
                }
                _ctx.SaveChanges();
            }
            catch (Exception e)
            {
                var error = e;
                throw;
            }


            return(true);
        }
示例#2
0
 public void Create(Role role)
 {
     _prContext.Entry(role).State = Microsoft.EntityFrameworkCore.EntityState.Added;
     _prContext.SaveChanges();
 }
示例#3
0
 public User Update(User user)
 {
     _ctx.Entry(user).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
     _ctx.SaveChanges();
     return(user);
 }