Example #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));
        }
Example #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));
        }
Example #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));
        }
Example #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());
        }
Example #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());
        }
Example #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));
        }