Ejemplo n.º 1
0
        public static UserDto CreateNewUser(NebulaDbContext dbContext, UserUpsertDto userToCreate, string loginName, Guid userGuid)
        {
            if (!userToCreate.RoleID.HasValue)
            {
                return(null);
            }

            var user = new User
            {
                UserGuid   = userGuid,
                LoginName  = loginName,
                Email      = userToCreate.Email,
                FirstName  = userToCreate.FirstName,
                LastName   = userToCreate.LastName,
                IsActive   = true,
                RoleID     = userToCreate.RoleID.Value,
                CreateDate = DateTime.UtcNow,
            };

            dbContext.User.Add(user);
            dbContext.SaveChanges();
            dbContext.Entry(user).Reload();

            return(GetByUserID(dbContext, user.UserID));
        }
Ejemplo n.º 2
0
        public static UserDto UpdateUserGuid(NebulaDbContext dbContext, int userID, Guid userGuid)
        {
            var user = dbContext.User
                       .Single(x => x.UserID == userID);

            user.UserGuid   = userGuid;
            user.UpdateDate = DateTime.UtcNow;

            dbContext.SaveChanges();
            dbContext.Entry(user).Reload();
            return(GetByUserID(dbContext, userID));
        }
Ejemplo n.º 3
0
        public static UserDto SetDisclaimerAcknowledgedDate(NebulaDbContext dbContext, int userID)
        {
            var user = dbContext.User.Single(x => x.UserID == userID);

            user.UpdateDate = DateTime.UtcNow;
            user.DisclaimerAcknowledgedDate = DateTime.UtcNow;

            dbContext.SaveChanges();
            dbContext.Entry(user).Reload();

            return(GetByUserID(dbContext, userID));
        }
Ejemplo n.º 4
0
        public static CustomRichTextDto UpdateCustomRichText(NebulaDbContext dbContext, int customRichTextTypeID,
                                                             CustomRichTextDto customRichTextUpdateDto)
        {
            var customRichText = dbContext.CustomRichText
                                 .SingleOrDefault(x => x.CustomRichTextTypeID == customRichTextTypeID);

            // null check occurs in calling endpoint method.
            customRichText.CustomRichTextContent = customRichTextUpdateDto.CustomRichTextContent;

            dbContext.SaveChanges();

            return(customRichText.AsDto());
        }
Ejemplo n.º 5
0
        public static FieldDefinitionDto UpdateFieldDefinition(NebulaDbContext dbContext, int FieldDefinitionTypeID,
                                                               FieldDefinitionDto FieldDefinitionUpdateDto)
        {
            var fieldDefinition = dbContext.FieldDefinition
                                  .Include(x => x.FieldDefinitionType)
                                  .SingleOrDefault(x => x.FieldDefinitionTypeID == FieldDefinitionTypeID);

            // null check occurs in calling endpoint method.
            fieldDefinition.FieldDefinitionValue = FieldDefinitionUpdateDto.Definition;

            dbContext.SaveChanges();

            return(fieldDefinition.AsDto());
        }
Ejemplo n.º 6
0
        public static UserDto UpdateUserEntity(NebulaDbContext dbContext, int userID, UserUpsertDto userEditDto)
        {
            if (!userEditDto.RoleID.HasValue)
            {
                return(null);
            }

            var user = dbContext.User
                       .Include(x => x.Role)
                       .Single(x => x.UserID == userID);

            user.RoleID = userEditDto.RoleID.Value;
            user.ReceiveSupportEmails = userEditDto.RoleID.Value == 1 && userEditDto.ReceiveSupportEmails;
            user.UpdateDate           = DateTime.UtcNow;

            dbContext.SaveChanges();
            dbContext.Entry(user).Reload();
            return(GetByUserID(dbContext, userID));
        }